Skip to content

Commit

Permalink
Camel-Case-Expansion: alias by Property names, not Pathes
Browse files Browse the repository at this point in the history
This fixes issue #77
This *is* a breaking change
  • Loading branch information
iilei committed Aug 22, 2018
1 parent 82f4ea5 commit 6763c93
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ function parse (args, opts) {
unsetDefaulted(key)

if (/-/.test(key) && configuration['camel-case-expansion']) {
addNewAlias(key, camelCase(key))
var alias = key.split('.').map(function (prop) {
return camelCase(prop)
}).join('.')
addNewAlias(key, alias)
}

var value = processValue(key, val)
Expand Down
9 changes: 9 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,15 @@ describe('yargs-parser', function () {

argv.fooBar.should.equal(99)
})

// Fixes: https://github.com/yargs/yargs-parser/issues/77
it('should combine dot-notation and camel-case expansion', function () {
var argv = parser(['--dot-notation.foo.bar'])

argv.should.satisfy(function (args) {
return args.dotNotation.foo.bar
})
})
})

it('should define option as boolean and set default to true', function () {
Expand Down

0 comments on commit 6763c93

Please sign in to comment.