Skip to content

Commit

Permalink
[Fix] consider aliases when testing boolean long option value against…
Browse files Browse the repository at this point in the history
… 'false'

Fixes #30.
  • Loading branch information
shadowspawn authored and ljharb committed Apr 8, 2023
1 parent 2758c33 commit de53490
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ module.exports = function (args, opts) {
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
key = m[1];
var value = m[2];
if (flags.bools[key]) {
if (isBooleanKey(key)) {
value = value !== 'false';
}
setArg(key, value, arg);
Expand Down
12 changes: 12 additions & 0 deletions test/bool.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ test('supplied default for boolean using alias', function (t) {
b: true,
_: ['moo'],
});
t.end();
});

test('boolean and alias --boool=false', function (t) {
var parsed = parse(['--boool=false'], {
default: {
b: true,
},
alias: { b: 'boool' },
boolean: ['b'],
});

t.same(parsed.boool, false);
t.end();
});

0 comments on commit de53490

Please sign in to comment.