Skip to content

Commit

Permalink
revert: make requiresArg work in conjunction with arrays (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull authored and bcoe committed Nov 19, 2018
1 parent 1eb726b commit f4a3063
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -180,12 +180,12 @@ function parse (args, opts) {
)) {
key = arg.match(/^--?(.+)/)[1]

// array format = '--foo a b c'
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)) {
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) {
i = eatArray(i, key, args)
} else {
next = args[i + 1]

Expand Down
11 changes: 0 additions & 11 deletions test/yargs-parser.js
Expand Up @@ -1774,17 +1774,6 @@ 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 () {
Expand Down

0 comments on commit f4a3063

Please sign in to comment.