Skip to content

Commit 48b02f0

Browse files
authored
Improve 2.x executable subcommand tracking and update dependencies (#1059)
* Improve executable subcommand tracking * Update dev dependencies * Add 2.20.1 to CHANGELOG * 2.20.1
1 parent 3e8bf54 commit 48b02f0

File tree

4 files changed

+852
-727
lines changed

4 files changed

+852
-727
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.20.1 / 2019-09-29
2+
==================
3+
4+
* Improve executable subcommand tracking
5+
* Update dev dependencies
16

27
2.20.0 / 2019-04-02
38
==================

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Option.prototype.is = function(arg) {
9999
function Command(name) {
100100
this.commands = [];
101101
this.options = [];
102-
this._execs = {};
102+
this._execs = new Set();
103103
this._allowUnknownOption = false;
104104
this._args = [];
105105
this._name = name || '';
@@ -178,7 +178,7 @@ Command.prototype.command = function(name, desc, opts) {
178178
if (desc) {
179179
cmd.description(desc);
180180
this.executables = true;
181-
this._execs[cmd._name] = true;
181+
this._execs.add(cmd._name);
182182
if (opts.isDefault) this.defaultExecutable = cmd._name;
183183
}
184184
cmd._noHelp = !!opts.noHelp;
@@ -484,7 +484,7 @@ Command.prototype.parse = function(argv) {
484484
})[0];
485485
}
486486

487-
if (this._execs[name] && typeof this._execs[name] !== 'function') {
487+
if (this._execs.has(name)) {
488488
return this.executeSubCommand(argv, args, parsed.unknown);
489489
} else if (aliasCommand) {
490490
// is alias of a subCommand

0 commit comments

Comments
 (0)