has-flag
Advanced tools
Comparing version 3.0.0 to 4.0.0
10
index.js
'use strict'; | ||
module.exports = (flag, argv) => { | ||
argv = argv || process.argv; | ||
module.exports = (flag, argv = process.argv) => { | ||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); | ||
const pos = argv.indexOf(prefix + flag); | ||
const terminatorPos = argv.indexOf('--'); | ||
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); | ||
const position = argv.indexOf(prefix + flag); | ||
const terminatorPosition = argv.indexOf('--'); | ||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); | ||
}; |
{ | ||
"name": "has-flag", | ||
"version": "3.0.0", | ||
"description": "Check if argv has a specific flag", | ||
"license": "MIT", | ||
"repository": "sindresorhus/has-flag", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"has", | ||
"check", | ||
"detect", | ||
"contains", | ||
"find", | ||
"flag", | ||
"cli", | ||
"command-line", | ||
"argv", | ||
"process", | ||
"arg", | ||
"args", | ||
"argument", | ||
"arguments", | ||
"getopt", | ||
"minimist", | ||
"optimist" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "has-flag", | ||
"version": "4.0.0", | ||
"description": "Check if argv has a specific flag", | ||
"license": "MIT", | ||
"repository": "sindresorhus/has-flag", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"has", | ||
"check", | ||
"detect", | ||
"contains", | ||
"find", | ||
"flag", | ||
"cli", | ||
"command-line", | ||
"argv", | ||
"process", | ||
"arg", | ||
"args", | ||
"argument", | ||
"arguments", | ||
"getopt", | ||
"minimist", | ||
"optimist" | ||
], | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -7,3 +7,17 @@ # has-flag [![Build Status](https://travis-ci.org/sindresorhus/has-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/has-flag) | ||
--- | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> | ||
--- | ||
## Install | ||
@@ -69,4 +83,9 @@ | ||
## Security | ||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
4419
5
35
90
0
3