From 2dbe86b1d6dba7d1d2d54de6a0171c42f8b75cae Mon Sep 17 00:00:00 2001 From: Esteban Date: Fri, 8 Apr 2016 20:59:07 -0300 Subject: [PATCH] fix(boolean): fix for boolean options with non boolean defaults (#20) --- index.js | 2 +- test/yargs-parser.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 25943502..83c69c2c 100644 --- a/index.js +++ b/index.js @@ -497,7 +497,7 @@ function parse (args, opts) { o[key] = increment(o[key]) } else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) { o[key] = Array.isArray(value) ? value : [value] - } else if (o[key] === undefined || typeof o[key] === 'boolean') { + } else if (o[key] === undefined || checkAllAliases(key, flags.bools)) { o[key] = value } else if (Array.isArray(o[key])) { o[key].push(value) diff --git a/test/yargs-parser.js b/test/yargs-parser.js index 00e5b53d..0858b19d 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -879,7 +879,7 @@ describe('yargs-parser', function () { }) describe('for boolean options', function () { - [true, false, undefined].forEach(function (def) { + [true, false, undefined, null].forEach(function (def) { describe('with explicit ' + def + ' default', function () { var opts = { default: {