source: trip-planner-front/node_modules/has-flag/readme.md@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 986 bytes
Line 
1# has-flag [![Build Status](https://travis-ci.org/sindresorhus/has-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/has-flag)
2
3> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
4
5Correctly stops looking after an `--` argument terminator.
6
7
8## Install
9
10```
11$ npm install has-flag
12```
13
14
15## Usage
16
17```js
18// foo.js
19const hasFlag = require('has-flag');
20
21hasFlag('unicorn');
22//=> true
23
24hasFlag('--unicorn');
25//=> true
26
27hasFlag('f');
28//=> true
29
30hasFlag('-f');
31//=> true
32
33hasFlag('foo=bar');
34//=> true
35
36hasFlag('foo');
37//=> false
38
39hasFlag('rainbow');
40//=> false
41```
42
43```
44$ node foo.js -f --unicorn --foo=bar -- --rainbow
45```
46
47
48## API
49
50### hasFlag(flag, [argv])
51
52Returns a boolean for whether the flag exists.
53
54#### flag
55
56Type: `string`
57
58CLI flag to look for. The `--` prefix is optional.
59
60#### argv
61
62Type: `string[]`<br>
63Default: `process.argv`
64
65CLI arguments.
66
67
68## License
69
70MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracBrowser for help on using the repository browser.