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

Add support for multiple aliases #1236

Merged
merged 5 commits into from
Apr 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'develop' into feature/multiple-aliases
  • Loading branch information
shadowspawn committed Apr 4, 2020
commit 94e3d3f5380b022178c655f45bc8266108b67ce4
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,16 +1223,14 @@ class Command extends EventEmitter {
*/

alias(alias) {
if (alias === undefined) return this._alias;
if (alias === undefined) return this._alias[0]; // just return first, for backwards compatibility

let command = this;
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
// assume adding alias for last added executable subcommand, rather than this
command = this.commands[this.commands.length - 1];
}

if (arguments.length === 0) return command._alias[0]; // just return first, and return string not array for backwards compatibility

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

command._alias.push(alias);
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.