diff options
Diffstat (limited to 'node_modules/has-flag')
-rw-r--r-- | node_modules/has-flag/index.d.ts | 39 | ||||
-rw-r--r-- | node_modules/has-flag/index.js | 10 | ||||
-rw-r--r-- | node_modules/has-flag/package.json | 34 | ||||
-rw-r--r-- | node_modules/has-flag/readme.md | 19 |
4 files changed, 81 insertions, 21 deletions
diff --git a/node_modules/has-flag/index.d.ts b/node_modules/has-flag/index.d.ts new file mode 100644 index 000000000..a0a48c891 --- /dev/null +++ b/node_modules/has-flag/index.d.ts @@ -0,0 +1,39 @@ +/** +Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag. + +@param flag - CLI flag to look for. The `--` prefix is optional. +@param argv - CLI arguments. Default: `process.argv`. +@returns Whether the flag exists. + +@example +``` +// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow + +// foo.ts +import hasFlag = require('has-flag'); + +hasFlag('unicorn'); +//=> true + +hasFlag('--unicorn'); +//=> true + +hasFlag('f'); +//=> true + +hasFlag('-f'); +//=> true + +hasFlag('foo=bar'); +//=> true + +hasFlag('foo'); +//=> false + +hasFlag('rainbow'); +//=> false +``` +*/ +declare function hasFlag(flag: string, argv?: string[]): boolean; + +export = hasFlag; diff --git a/node_modules/has-flag/index.js b/node_modules/has-flag/index.js index 5139728fb..b6f80b1f8 100644 --- a/node_modules/has-flag/index.js +++ b/node_modules/has-flag/index.js @@ -1,8 +1,8 @@ '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); }; diff --git a/node_modules/has-flag/package.json b/node_modules/has-flag/package.json index 4bcd2125a..3f411621c 100644 --- a/node_modules/has-flag/package.json +++ b/node_modules/has-flag/package.json @@ -1,27 +1,27 @@ { - "_from": "has-flag@^3.0.0", - "_id": "has-flag@3.0.0", + "_from": "has-flag@^4.0.0", + "_id": "has-flag@4.0.0", "_inBundle": false, - "_integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "_integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "_location": "/has-flag", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "has-flag@^3.0.0", + "raw": "has-flag@^4.0.0", "name": "has-flag", "escapedName": "has-flag", - "rawSpec": "^3.0.0", + "rawSpec": "^4.0.0", "saveSpec": null, - "fetchSpec": "^3.0.0" + "fetchSpec": "^4.0.0" }, "_requiredBy": [ "/supports-color" ], - "_resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "_shasum": "b5d454dc2199ae225699f3467e5a07f3b955bafd", - "_spec": "has-flag@^3.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/supports-color", + "_resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "_shasum": "944771fd9c81c81265c4d6941860da06bb59479b", + "_spec": "has-flag@^4.0.0", + "_where": "/Users/isaacs/dev/npm/cli/node_modules/supports-color", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -34,14 +34,16 @@ "deprecated": false, "description": "Check if argv has a specific flag", "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.4.1", + "tsd": "^0.7.2", + "xo": "^0.24.0" }, "engines": { - "node": ">=4" + "node": ">=8" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "homepage": "https://github.com/sindresorhus/has-flag#readme", "keywords": [ @@ -70,7 +72,7 @@ "url": "git+https://github.com/sindresorhus/has-flag.git" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd" }, - "version": "3.0.0" + "version": "4.0.0" } diff --git a/node_modules/has-flag/readme.md b/node_modules/has-flag/readme.md index 677893c27..3f72dff29 100644 --- a/node_modules/has-flag/readme.md +++ b/node_modules/has-flag/readme.md @@ -4,6 +4,20 @@ Correctly stops looking after an `--` argument terminator. +--- + +<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 @@ -65,6 +79,11 @@ Default: `process.argv` CLI arguments. +## 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) |