has-flag
- Version 5.0.1
- Published
- 4.29 kB
- No dependencies
- MIT license
Install
npm i has-flag
yarn add has-flag
pnpm add has-flag
Overview
Check if argv has a specific flag
Index
Functions
Functions
function hasFlag
hasFlag: (flag: string, argv?: readonly string[]) => boolean;
Check if [
argv
](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.Parameter flag
CLI flag to look for. The
--
prefix is optional.Parameter argv
CLI arguments. Default:
process.argv
.Returns
Whether the flag exists.
It correctly stops looking after an
--
argument terminator.Example 1
// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow// foo.tsimport hasFlag from 'has-flag';hasFlag('unicorn');//=> truehasFlag('--unicorn');//=> truehasFlag('f');//=> truehasFlag('-f');//=> truehasFlag('foo=bar');//=> truehasFlag('foo');//=> falsehasFlag('rainbow');//=> false
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (3)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/has-flag
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/has-flag)
- HTML<a href="https://www.jsdocs.io/package/has-flag"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2639 ms. - Missing or incorrect documentation? Open an issue for this package.