Skip to content

Commit

Permalink
Improve executable subcommand tracking (#1056)
Browse files Browse the repository at this point in the history
* Track executables better

* Bump version for release

* Update dependencies
  • Loading branch information
shadowspawn authored Sep 26, 2019
1 parent 4312302 commit 2544df8
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 146 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.)

## [3.0.2] (2019-09-27)

### Fixed

* Improve tracking of executable subcommands.

### Changed

* update development dependencies

## [3.0.1] (2019-08-30)

### Added
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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 @@ -149,7 +149,7 @@ Command.prototype.command = function(nameAndArgs, actionOptsOrExecDesc, execOpts
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 @@ -498,7 +498,7 @@ Command.prototype.parse = function(argv) {
});
}

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

Expand Down
Loading

0 comments on commit 2544df8

Please sign in to comment.