Skip to content

Commit

Permalink
fix: conflicting options now properly override each other (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfischer authored and ariporad committed Jul 27, 2016
1 parent add14ad commit 06ae7d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function parseOptions(opt, map) {
if (c in map) {
optionName = map[c];
if (optionName[0] === '!')
options[optionName.slice(1, optionName.length-1)] = false;
options[optionName.slice(1)] = false;
else
options[optionName] = true;
} else {
Expand Down
9 changes: 7 additions & 2 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ assert.ok(result.no_force === false);
assert.ok(result.force === undefined); // this key shouldn't exist

// common.parseOptions (the last of the conflicting options should hold)
result = common.parseOptions('-fn', {
var options = {
'n': 'no_force',
'f': '!no_force',
'R': 'recursive'
});
};
result = common.parseOptions('-fn', options);
assert.ok(result.recursive === false);
assert.ok(result.no_force === true);
assert.ok(result.force === undefined); // this key shouldn't exist
result = common.parseOptions('-nf', options);
assert.ok(result.recursive === false);
assert.ok(result.no_force === false);
assert.ok(result.force === undefined); // this key shouldn't exist

// common.parseOptions using an object to hold options
result = common.parseOptions({'-v': 'some text here'}, {
Expand Down

0 comments on commit 06ae7d9

Please sign in to comment.