Skip to content

Commit d8b14f9

Browse files
zyrolastingbcoe
authored andcommitted
fix: allow null config values (#108)
1 parent c7eee91 commit d8b14f9

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function parse (args, opts) {
479479
// if the value is an inner object and we have dot-notation
480480
// enabled, treat inner objects in config the same as
481481
// heavily nested dot notations (foo.bar.apple).
482-
if (typeof value === 'object' && !Array.isArray(value) && configuration['dot-notation']) {
482+
if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
483483
// if the value is an object but not an array, check nested object
484484
setConfigObject(value, fullKey)
485485
} else {

test/yargs-parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,15 @@ describe('yargs-parser', function () {
642642
configObjects: [{
643643
apple: 'apple',
644644
banana: 42,
645-
foo: 'baz'
645+
foo: 'baz',
646+
gotcha: null
646647
}]
647648
})
648649

649650
argv.should.have.property('apple', 'apple')
650651
argv.should.have.property('banana', 42)
651652
argv.should.have.property('foo', 'bar')
653+
argv.should.have.property('gotcha', null)
652654
})
653655

654656
it('should use value from config object, if argv value is using default value', function () {

0 commit comments

Comments
 (0)