Initial commit
[yaffs-website] / node_modules / has-flag / readme.md
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
5 Correctly stops looking after an `--` argument terminator.
6
7
8 ## Install
9
10 ```
11 $ npm install --save has-flag
12 ```
13
14
15 ## Usage
16
17 ```js
18 // foo.js
19 var hasFlag = require('has-flag');
20
21 hasFlag('unicorn');
22 //=> true
23
24 hasFlag('--unicorn');
25 //=> true
26
27 hasFlag('foo=bar');
28 //=> true
29
30 hasFlag('foo');
31 //=> false
32
33 hasFlag('rainbow');
34 //=> false
35 ```
36
37 ```
38 $ node foo.js --unicorn --foo=bar -- --rainbow
39 ```
40
41
42 ## API
43
44 ### hasFlag(flag, [argv])
45
46 Returns a boolean whether the flag exists.
47
48 #### flag
49
50 Type: `string`
51
52 CLI flag to look for. The `--` prefix is optional.
53
54 #### argv
55
56 Type: `array`  
57 Default: `process.argv`
58
59 CLI arguments.
60
61
62 ## License
63
64 MIT © [Sindre Sorhus](http://sindresorhus.com)