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 9<div align="center"> 10 <b> 11 <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> 12 </b> 13 <br> 14 <sub> 15 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. 16 </sub> 17</div> 18 19--- 20 21 22## Install 23 24``` 25$ npm install has-flag 26``` 27 28 29## Usage 30 31```js 32// foo.js 33const hasFlag = require('has-flag'); 34 35hasFlag('unicorn'); 36//=> true 37 38hasFlag('--unicorn'); 39//=> true 40 41hasFlag('f'); 42//=> true 43 44hasFlag('-f'); 45//=> true 46 47hasFlag('foo=bar'); 48//=> true 49 50hasFlag('foo'); 51//=> false 52 53hasFlag('rainbow'); 54//=> false 55``` 56 57``` 58$ node foo.js -f --unicorn --foo=bar -- --rainbow 59``` 60 61 62## API 63 64### hasFlag(flag, [argv]) 65 66Returns a boolean for whether the flag exists. 67 68#### flag 69 70Type: `string` 71 72CLI flag to look for. The `--` prefix is optional. 73 74#### argv 75 76Type: `string[]`<br> 77Default: `process.argv` 78 79CLI arguments. 80 81 82## Security 83 84To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. 85 86 87## License 88 89MIT © [Sindre Sorhus](https://sindresorhus.com) 90