blob: cf60795caf5889f3b670101c22056fb3ebff2fb2 [file] [log] [blame] [edit]
import process from 'process'; // eslint-disable-line node/prefer-global/process
export default function hasFlag(flag, argv = process.argv) {
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
const position = argv.indexOf(prefix + flag);
const terminatorPosition = argv.indexOf('--');
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
}