Skip to content

Commit 2544df8

Browse files
authored
Improve executable subcommand tracking (#1056)
* Track executables better * Bump version for release * Update dependencies
1 parent 4312302 commit 2544df8

File tree

4 files changed

+203
-146
lines changed

4 files changed

+203
-146
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.)
77

8+
## [3.0.2] (2019-09-27)
9+
10+
### Fixed
11+
12+
* Improve tracking of executable subcommands.
13+
14+
### Changed
15+
16+
* update development dependencies
17+
818
## [3.0.1] (2019-08-30)
919

1020
### Added

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Option.prototype.is = function(arg) {
9797
function Command(name) {
9898
this.commands = [];
9999
this.options = [];
100-
this._execs = {};
100+
this._execs = new Set();
101101
this._allowUnknownOption = false;
102102
this._args = [];
103103
this._name = name || '';
@@ -149,7 +149,7 @@ Command.prototype.command = function(nameAndArgs, actionOptsOrExecDesc, execOpts
149149
if (desc) {
150150
cmd.description(desc);
151151
this.executables = true;
152-
this._execs[cmd._name] = true;
152+
this._execs.add(cmd._name);
153153
if (opts.isDefault) this.defaultExecutable = cmd._name;
154154
}
155155
cmd._noHelp = !!opts.noHelp;
@@ -498,7 +498,7 @@ Command.prototype.parse = function(argv) {
498498
});
499499
}
500500

501-
if (this._execs[name] && typeof this._execs[name] !== 'function') {
501+
if (this._execs.has(name)) {
502502
return this.executeSubCommand(argv, args, parsed.unknown, subCommand ? subCommand._executableFile : undefined);
503503
}
504504

0 commit comments

Comments
 (0)