Skip to content

Commit 2dbe86b

Browse files
elas7bcoe
authored andcommitted
fix(boolean): fix for boolean options with non boolean defaults (#20)
1 parent 0353c0d commit 2dbe86b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ function parse (args, opts) {
497497
o[key] = increment(o[key])
498498
} else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) {
499499
o[key] = Array.isArray(value) ? value : [value]
500-
} else if (o[key] === undefined || typeof o[key] === 'boolean') {
500+
} else if (o[key] === undefined || checkAllAliases(key, flags.bools)) {
501501
o[key] = value
502502
} else if (Array.isArray(o[key])) {
503503
o[key].push(value)

test/yargs-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ describe('yargs-parser', function () {
879879
})
880880

881881
describe('for boolean options', function () {
882-
[true, false, undefined].forEach(function (def) {
882+
[true, false, undefined, null].forEach(function (def) {
883883
describe('with explicit ' + def + ' default', function () {
884884
var opts = {
885885
default: {

0 commit comments

Comments
 (0)