Skip to content

Commit 3e47d62

Browse files
authored
fix: parsing hints should apply for dot notation keys (#86)
1 parent f1903aa commit 3e47d62

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ function parse (args, opts) {
564564

565565
var key = keys[keys.length - 1]
566566

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

test/yargs-parser.js

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

20572057
parsed['x'].should.deep.equal(['a', 'b'])
20582058
})
2059+
2060+
it('flattens duplicate array type, when argument uses dot notation', function () {
2061+
var parsed = parser('-x.foo a -x.foo b', {
2062+
array: ['x.foo'],
2063+
configuration: {
2064+
'flatten-duplicate-arrays': true
2065+
}
2066+
})
2067+
2068+
parsed['x'].should.deep.equal({foo: ['a', 'b']})
2069+
})
20592070
})
20602071

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

0 commit comments

Comments
 (0)