Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail when using same command and alias #491

Merged
merged 1 commit into from Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -880,6 +880,8 @@ Command.prototype.alias = function(alias) {

if (arguments.length === 0) return command._alias;

if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');

command._alias = alias;
return this;
};
Expand Down
14 changes: 14 additions & 0 deletions test/test.command.failOnSameAlias.js
@@ -0,0 +1,14 @@
var program = require('../')
, should = require('should');

var error;

try {
program
.command('fail')
.alias('fail');
} catch (e) {
error = e;
}

error.should.deepEqual(new Error('Command alias can\'t be the same as its name'));