Skip to content

Commit

Permalink
Never call preSubcommand hooks on help command
Browse files Browse the repository at this point in the history
  • Loading branch information
aweebit committed Aug 13, 2023
1 parent 8dd417f commit 77828ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
if (!subcommandName) {
this.help();
}

const subCommand = this._findCommand(subcommandName);
if (subCommand && !subCommand._executableHandler) {
if (!subCommand) {
this.help({ error: true });
}
if (!subCommand._executableHandler) {
subCommand.help();
}

// Fallback to parsing the help flag to invoke the help.
return this._dispatchSubcommand(subcommandName, [], [
this._executeSubCommand(subcommandName, [
this._helpLongFlag || this._helpShortFlag
]);
}
Expand Down

0 comments on commit 77828ba

Please sign in to comment.