Skip to content

Commit

Permalink
Handle commander.js passing arg object when nick is not provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffano committed Jan 9, 2013
1 parent 672671c commit 157589b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/cli.js
Expand Up @@ -116,6 +116,7 @@ function _version() {
}

function _irc(host, channel, nick) {
nick = (typeof nick === 'string') ? nick : undefined;
irc.start(host, channel, nick);
}

Expand Down
3 changes: 2 additions & 1 deletion test/cli.js
Expand Up @@ -427,10 +427,11 @@ buster.testCase('cli - irc', {
this.mockIrc = this.mock(irc);
},
'should start irc bot with undefined nick when irc command is called with host and channel args only': function () {
// nick argument is an object because commander passes the whole arg object when cli only has host and channel args
this.mockIrc.expects('start').once().withExactArgs('somehost', 'somechannel', undefined);
this.stub(bag, 'cli', {
command: function (base, actions) {
actions.commands.irc.action('somehost', 'somechannel');
actions.commands.irc.action('somehost', 'somechannel', {});
},
exitCb: bag.cli.exitCb
});
Expand Down

0 comments on commit 157589b

Please sign in to comment.