fix: take into account aliases when appending arrays from config obje… · yargs/yargs-parser@f8a2d3f

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -555,7 +555,7 @@ function parse (args, opts) {

555555

} else {

556556

// setting arguments via CLI takes precedence over

557557

// values within the config file.

558-

if (!hasKey(argv, fullKey.split('.')) || (flags.arrays[fullKey] && configuration['combine-arrays'])) {

558+

if (!hasKey(argv, fullKey.split('.')) || (checkAllAliases(fullKey, flags.arrays) && configuration['combine-arrays'])) {

559559

setArg(fullKey, value)

560560

}

561561

}

Original file line numberDiff line numberDiff line change

@@ -774,6 +774,21 @@ describe('yargs-parser', function () {

774774

argv.should.have.property('foo', 'bar')

775775

argv.should.have.property('bar', 'baz')

776776

})

777+
778+

it('should combine array typed options with alias and camel-case', function () {

779+

var argv = parser(['--camEl', 'foo', '--camEl', 'bar', '-a', 'red'], {

780+

array: ['cam-el', 'apple'],

781+

alias: { apple: 'a' },

782+

configObjects: [{ camEl: 'baz' }, { a: 'sweet' }],

783+

configuration: {

784+

'combine-arrays': true,

785+

'camel-case-expansion': true

786+

}

787+

})

788+
789+

argv['cam-el'].should.deep.equal(['foo', 'bar', 'baz'])

790+

argv.apple.should.deep.equal(['red', 'sweet'])

791+

})

777792

})

778793
779794

describe('dot notation', function () {