Skip to content

Commit

Permalink
Make passThroughOptions continue processing at unknown options
Browse files Browse the repository at this point in the history
So that the help option is correctly consumed.
  • Loading branch information
aweebit committed Aug 4, 2023
1 parent 02fde0e commit eae6c5f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -1557,13 +1557,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
}
}

// An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands.
if (maybeOption(arg)) {
// An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands.
dest = unknown;
}

// If using passThroughOptions, stop processing options at first command-argument / unknown option.
if (this._passThroughOptions) {
} else if (this._passThroughOptions) {
// If using passThroughOptions, stop processing options at first command-argument.
// Do not stop at unknown option
// - so that known options after it and before a subcommand / command-argument are consumed by the parent command (including the help option);
// - and because that is simply not what passThroughOptions is supposed to do.
dest.push(arg, ...args);
break;
}
Expand Down

0 comments on commit eae6c5f

Please sign in to comment.