Skip to content

Commit

Permalink
fix(boolean): fix for boolean options with non boolean defaults (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
elas7 authored and bcoe committed Apr 8, 2016
1 parent 0353c0d commit 2dbe86b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 2dbe86b

Please sign in to comment.