fb96dada3acb704d8dc5e53a3c175219152f043f0b4f72407c3925a9830ad2b8884a88fb06c81d70601ae0f3e70fd41902545c8862cda3907f248e9aac412f 927 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # has-flag [![Build Status](https://travis-ci.org/sindresorhus/has-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/has-flag)
  2. > Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
  3. Correctly stops looking after an `--` argument terminator.
  4. ## Install
  5. ```
  6. $ npm install --save has-flag
  7. ```
  8. ## Usage
  9. ```js
  10. // foo.js
  11. var hasFlag = require('has-flag');
  12. hasFlag('unicorn');
  13. //=> true
  14. hasFlag('--unicorn');
  15. //=> true
  16. hasFlag('foo=bar');
  17. //=> true
  18. hasFlag('foo');
  19. //=> false
  20. hasFlag('rainbow');
  21. //=> false
  22. ```
  23. ```
  24. $ node foo.js --unicorn --foo=bar -- --rainbow
  25. ```
  26. ## API
  27. ### hasFlag(flag, [argv])
  28. Returns a boolean whether the flag exists.
  29. #### flag
  30. Type: `string`
  31. CLI flag to look for. The `--` prefix is optional.
  32. #### argv
  33. Type: `array`
  34. Default: `process.argv`
  35. CLI arguments.
  36. ## License
  37. MIT © [Sindre Sorhus](http://sindresorhus.com)