7fife-backend/node_modules/has-flag
Nawaaz b8a5323689 updated code 2024-03-11 17:59:54 +05:30
..
index.js update code 2024-03-07 18:31:44 +05:30
license update code 2024-03-07 18:31:44 +05:30
package.json updated code 2024-03-11 17:59:54 +05:30
readme.md update code 2024-03-07 18:31:44 +05:30

readme.md

has-flag Build Status

Check if argv has a specific flag

Correctly stops looking after an -- argument terminator.

Install

$ npm install has-flag

Usage

// foo.js
const 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
$ node foo.js -f --unicorn --foo=bar -- --rainbow

API

hasFlag(flag, [argv])

Returns a boolean for whether the flag exists.

flag

Type: string

CLI flag to look for. The -- prefix is optional.

argv

Type: string[]
Default: process.argv

CLI arguments.

License

MIT © Sindre Sorhus