Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve executable subcommand tracking #1056

Merged
merged 3 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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