Skip to content

Commit

Permalink
Merge pull request dthree#315 from mdouglass/master
Browse files Browse the repository at this point in the history
Fix dthree#270: Fix check for undefined commands so that it does not catch the string 'undefine'
  • Loading branch information
milesj authored Aug 15, 2018
2 parents 3bb1453 + 7e73caa commit 98d29ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ vorpal._exec = function (item) {
throw new Error('Fatal Error: No session was passed into command for execution: ' + item);
}

if (String(item.command).indexOf('undefine') > -1) {
if (item.command === undefined) {
throw new Error('vorpal._exec was called with an undefined command.');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ vorpal._exec = function (item) {
throw new Error('Fatal Error: No session was passed into command for execution: ' + item);
}

if (String(item.command).indexOf('undefine') > -1) {
if (item.command === undefined) {
throw new Error('vorpal._exec was called with an undefined command.');
}

Expand Down
5 changes: 5 additions & 0 deletions test/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ describe('argument parsing', function () {
var fixture = obj({ options: {}, variadic: ['and', 'so', 'on'] });
obj(vorpal.execSync('multi word command and so on')).should.equal(fixture);
});

it('should parse command with undefine in it as invalid', function () {
var fixture = obj("Invalid command.");
obj(vorpal.execSync('has undefine in it')).should.equal(fixture);
})
});

describe('option parsing', function () {
Expand Down

0 comments on commit 98d29ed

Please sign in to comment.