Skip to content
Myr

minor update

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by zhiyelee · committed by zhiyelee · parent afd6f49 · Browse files · 4 files+20 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+20 added−22 removed

  • tests:+3 added−11 removed
  • other:+17 added−11 removed

4 files+20 added−22 removed

modified:test/fixtures/pm+1 added-1 removed
5 unmodified lines
6 .version('0.0.1')7 .command('install [name]', 'install one or more packages').alias('i')8 .command('search [query]', 'search with optional query').alias('s')9 .command('cache', 'actions dealing with the cache').alias('c')10 .command('list', 'list packages installed').alias('l')10 .command('list', 'list packages installed')11 .command('publish', 'publish or update package').alias('p')12 .command('default', 'default command', {noHelp: true, isDefault: true})13 .parse(process.argv);
modified:test/test.command.executableSubcommandAlias.help.js+1 added-1 removed
modified:test/test.command.executableSubcommandAlias.js+1 added-9 removed
modified:index.js+17 added-11 removed
457 unmodified lines
458 var result = this.parseArgs(this.args, parsed.unknown);459460 // executable sub-commands461 var name = result.args[0];462 var aliasCommand = this.commands.filter(function(command) {463 var _alias = command.alias();464 return _alias !== undefined && _alias === name;465 })[0];462463 var aliasCommand = null;464 // check alias of sub commands465 if (name) {466 aliasCommand = this.commands.filter(function(command) {467 return command.alias() === name;468 })[0];469 }470471 if (this._execs[name] && typeof this._execs[name] != "function") {472 return this.executeSubCommand(argv, args, parsed.unknown);468 } else if (aliasCommand !== undefined) {473 } else if (aliasCommand) {474 // is alias of a subCommand475 args[0] = aliasCommand._name;476 return this.executeSubCommand(argv, args, parsed.unknown);477 } else if (this.defaultExecutable) {478 // use the default subcommand473 args.unshift(name = this.defaultExecutable);479 args.unshift(this.defaultExecutable);480 return this.executeSubCommand(argv, args, parsed.unknown);481 }482483 return result;
378 unmodified lines
862 * @api public863 */864865Command.prototype.alias = function(alias) {860 var command = undefined;861 if(this.commands.length == 0) {862 command = this;863 } else {866 var command = this;867 if(this.commands.length !== 0) {868 command = this.commands[this.commands.length - 1]869 }870866 if (0 == arguments.length) return command._alias;871 if (arguments.length === 0) return command._alias;872873 command._alias = alias;874 return this;875};876
253 unmodified lines