You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 lines
320 B

4 years ago
  1. 'use strict';
  2. module.exports = (flag, argv) => {
  3. argv = argv || process.argv;
  4. const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
  5. const pos = argv.indexOf(prefix + flag);
  6. const terminatorPos = argv.indexOf('--');
  7. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  8. };