1 | import process from 'process'; // eslint-disable-line node/prefer-global/process
|
2 |
|
3 | export default function hasFlag(flag, argv = process.argv) {
|
4 | const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
5 | const position = argv.indexOf(prefix + flag);
|
6 | const terminatorPosition = argv.indexOf('--');
|
7 | return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
8 | }
|