Skip to content

Commit

Permalink
Fix boolean aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
coderarity authored and James Halliday committed Apr 12, 2012
1 parent f14dda5 commit 4fb60bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ function Argv (args, cwd) {
var key = arg.slice(-1)[0];

if (args[i+1] && !args[i+1].match(/^-/)
&& !flags.bools[key]) {
&& !flags.bools[key]
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
setArg(key, args[i+1]);
i++;
}
Expand Down
4 changes: 2 additions & 2 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ test('boolean and alias with chainable api', function (t) {
};
var aliasedArgv = optimist(aliased)
.boolean('herp')
.alias('h')
.alias('h', 'herp')
.argv;
var propertyArgv = optimist(regular)
.boolean('herp')
.alias('h')
.alias('h', 'herp')
.argv;
var expected = {
herp: true,
Expand Down

0 comments on commit 4fb60bf

Please sign in to comment.