diff --git a/index.js b/index.js index caf8a646..e0054fd0 100644 --- a/index.js +++ b/index.js @@ -167,12 +167,12 @@ function parse (args, opts) { )) { key = arg.match(/^--?(.+)/)[1] - // nargs format = '--foo a b c' - if (checkAllAliases(key, flags.nargs)) { - i = eatNargs(i, key, args) // array format = '--foo a b c' - } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) { + if (checkAllAliases(key, flags.arrays) && args.length > i + 1) { i = eatArray(i, key, args) + // nargs format = '--foo a b c' + } else if (checkAllAliases(key, flags.nargs)) { + i = eatNargs(i, key, args) } else { next = args[i + 1] diff --git a/test/yargs-parser.js b/test/yargs-parser.js index b6e2396e..e483536e 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -1702,6 +1702,17 @@ describe('yargs-parser', function () { result.foo.should.eql('a') }) + + it('should be ignored if input is an array', function () { + var result = parser(['--foo', 'a', 'b'], { + array: 'foo', + narg: { + foo: 1 + } + }) + + result.foo.should.eql(['a', 'b']) + }) }) describe('env vars', function () {