Update has-flag.js

This commit is contained in:
paladox 2018-02-14 00:48:12 +00:00 committed by GitHub
parent 2dc605c8cd
commit 8d1da39bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,10 +11,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/
'use strict';
module.exports = (flag, argv) => {
module.exports = function(flag, argv) {
argv = argv || process.argv;
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
const pos = argv.indexOf(prefix + flag);
const terminatorPos = argv.indexOf('--');
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
var prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
var pos = argv.indexOf(prefix + flag);
var terminatorPos = argv.indexOf('--');
var pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
};