Skip to content

Commit f4a3063

Browse files
boneskullbcoe
authored andcommitted
revert: make requiresArg work in conjunction with arrays (#136)
1 parent 1eb726b commit f4a3063

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ function parse (args, opts) {
180180
)) {
181181
key = arg.match(/^--?(.+)/)[1]
182182

183-
// array format = '--foo a b c'
184-
if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
185-
i = eatArray(i, key, args)
186183
// nargs format = '--foo a b c'
187-
} else if (checkAllAliases(key, flags.nargs)) {
184+
if (checkAllAliases(key, flags.nargs)) {
188185
i = eatNargs(i, key, args)
186+
// array format = '--foo a b c'
187+
} else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
188+
i = eatArray(i, key, args)
189189
} else {
190190
next = args[i + 1]
191191

test/yargs-parser.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,17 +1774,6 @@ describe('yargs-parser', function () {
17741774

17751775
result.foo.should.eql('a')
17761776
})
1777-
1778-
it('should be ignored if input is an array', function () {
1779-
var result = parser(['--foo', 'a', 'b'], {
1780-
array: 'foo',
1781-
narg: {
1782-
foo: 1
1783-
}
1784-
})
1785-
1786-
result.foo.should.eql(['a', 'b'])
1787-
})
17881777
})
17891778

17901779
describe('env vars', function () {

0 commit comments

Comments
 (0)