Skip to content

Commit

Permalink
fix: hyphenated flags combined with dot notation broke parsing (#131)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the argv object is now populated differently (correctly) when hyphens and dot notation are used in conjunction.
  • Loading branch information
iilei authored and bcoe committed Oct 6, 2018
1 parent 0e366e3 commit dc788da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Expand Up @@ -372,7 +372,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
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 dc788da

Please sign in to comment.