Skip to content

Commit

Permalink
fix: allows camel-case, variadic arguments, and strict mode to be com…
Browse files Browse the repository at this point in the history
…bined (#1247)
  • Loading branch information
bcoe committed Nov 19, 2018
1 parent 331cb20 commit eacc035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/command.js
Expand Up @@ -358,6 +358,9 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {

Object.keys(parsed.argv).forEach((key) => {
if (positionalKeys.indexOf(key) !== -1) {
// any new aliases need to be placed in positionalMap, which
// is used for validation.
if (!positionalMap[key]) positionalMap[key] = parsed.argv[key]
argv[key] = parsed.argv[key]
}
})
Expand Down
11 changes: 11 additions & 0 deletions test/command.js
Expand Up @@ -184,6 +184,17 @@ describe('Command', () => {
argv.file.should.equal('file1')
argv._.should.include('file2')
})

// addresses: https://github.com/yargs/yargs/issues/1246
it('allows camel-case, variadic arguments, and strict mode to be combined', () => {
const argv = yargs('ls one two three')
.command('ls [expandMe...]')
.strict()
.parse()

argv.expandMe.should.deep.equal(['one', 'two', 'three'])
argv['expand-me'].should.deep.equal(['one', 'two', 'three'])
})
})

describe('missing positional arguments', () => {
Expand Down

0 comments on commit eacc035

Please sign in to comment.