index.js 330 B

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