Skip to content

Commit

Permalink
fix: parsing hints should apply for dot notation keys (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Apr 15, 2017
1 parent f1903aa commit 3e47d62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function parse (args, opts) {

var key = keys[keys.length - 1]

var isTypeArray = checkAllAliases(key, flags.arrays)
var isTypeArray = checkAllAliases(keys.join('.'), flags.arrays)
var isValueArray = Array.isArray(value)
var duplicate = configuration['duplicate-arguments-array']

Expand Down
11 changes: 11 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,17 @@ describe('yargs-parser', function () {

parsed['x'].should.deep.equal(['a', 'b'])
})

it('flattens duplicate array type, when argument uses dot notation', function () {
var parsed = parser('-x.foo a -x.foo b', {
array: ['x.foo'],
configuration: {
'flatten-duplicate-arrays': true
}
})

parsed['x'].should.deep.equal({foo: ['a', 'b']})
})
})

describe('duplicate-arguments-array VS flatten-duplicate-arrays', function () {
Expand Down

0 comments on commit 3e47d62

Please sign in to comment.