Skip to content

Commit

Permalink
Improve 2.x executable subcommand tracking and update dependencies (#…
Browse files Browse the repository at this point in the history
…1059)

* Improve executable subcommand tracking

* Update dev dependencies

* Add 2.20.1 to CHANGELOG

* 2.20.1
  • Loading branch information
shadowspawn committed Sep 28, 2019
1 parent 3e8bf54 commit 48b02f0
Show file tree
Hide file tree
Showing 4 changed files with 852 additions and 727 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.20.1 / 2019-09-29
==================

* Improve executable subcommand tracking
* Update dev dependencies

2.20.0 / 2019-04-02
==================
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Option.prototype.is = function(arg) {
function Command(name) {
this.commands = [];
this.options = [];
this._execs = {};
this._execs = new Set();
this._allowUnknownOption = false;
this._args = [];
this._name = name || '';
Expand Down Expand Up @@ -178,7 +178,7 @@ Command.prototype.command = function(name, desc, opts) {
if (desc) {
cmd.description(desc);
this.executables = true;
this._execs[cmd._name] = true;
this._execs.add(cmd._name);
if (opts.isDefault) this.defaultExecutable = cmd._name;
}
cmd._noHelp = !!opts.noHelp;
Expand Down Expand Up @@ -484,7 +484,7 @@ Command.prototype.parse = function(argv) {
})[0];
}

if (this._execs[name] && typeof this._execs[name] !== 'function') {
if (this._execs.has(name)) {
return this.executeSubCommand(argv, args, parsed.unknown);
} else if (aliasCommand) {
// is alias of a subCommand
Expand Down
Loading

0 comments on commit 48b02f0

Please sign in to comment.