From 3e47d62c62bdf41c03f84ca0105ddd1b10fe9879 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Sat, 15 Apr 2017 16:26:02 -0700 Subject: [PATCH] fix: parsing hints should apply for dot notation keys (#86) --- index.js | 2 +- test/yargs-parser.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 25554c14..4ac6fa9f 100644 --- a/index.js +++ b/index.js @@ -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'] diff --git a/test/yargs-parser.js b/test/yargs-parser.js index f30149c3..1fb0724f 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -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 () {