|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
684 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
|
|---|
| 3 |
|
|---|
| 4 | @param flag - CLI flag to look for. The `--` prefix is optional.
|
|---|
| 5 | @param argv - CLI arguments. Default: `process.argv`.
|
|---|
| 6 | @returns Whether the flag exists.
|
|---|
| 7 |
|
|---|
| 8 | @example
|
|---|
| 9 | ```
|
|---|
| 10 | // $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
|
|---|
| 11 |
|
|---|
| 12 | // foo.ts
|
|---|
| 13 | import hasFlag = require('has-flag');
|
|---|
| 14 |
|
|---|
| 15 | hasFlag('unicorn');
|
|---|
| 16 | //=> true
|
|---|
| 17 |
|
|---|
| 18 | hasFlag('--unicorn');
|
|---|
| 19 | //=> true
|
|---|
| 20 |
|
|---|
| 21 | hasFlag('f');
|
|---|
| 22 | //=> true
|
|---|
| 23 |
|
|---|
| 24 | hasFlag('-f');
|
|---|
| 25 | //=> true
|
|---|
| 26 |
|
|---|
| 27 | hasFlag('foo=bar');
|
|---|
| 28 | //=> true
|
|---|
| 29 |
|
|---|
| 30 | hasFlag('foo');
|
|---|
| 31 | //=> false
|
|---|
| 32 |
|
|---|
| 33 | hasFlag('rainbow');
|
|---|
| 34 | //=> false
|
|---|
| 35 | ```
|
|---|
| 36 | */
|
|---|
| 37 | declare function hasFlag(flag: string, argv?: string[]): boolean;
|
|---|
| 38 |
|
|---|
| 39 | export = hasFlag;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.