Skip to content

Commit eae6c5f

Browse files
committed
Make passThroughOptions continue processing at unknown options
So that the help option is correctly consumed.
1 parent 02fde0e commit eae6c5f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/command.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,13 +1557,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
15571557
}
15581558
}
15591559

1560-
// An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands.
15611560
if (maybeOption(arg)) {
1561+
// An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands.
15621562
dest = unknown;
1563-
}
1564-
1565-
// If using passThroughOptions, stop processing options at first command-argument / unknown option.
1566-
if (this._passThroughOptions) {
1563+
} else if (this._passThroughOptions) {
1564+
// If using passThroughOptions, stop processing options at first command-argument.
1565+
// Do not stop at unknown option
1566+
// - so that known options after it and before a subcommand / command-argument are consumed by the parent command (including the help option);
1567+
// - and because that is simply not what passThroughOptions is supposed to do.
15671568
dest.push(arg, ...args);
15681569
break;
15691570
}

0 commit comments

Comments
 (0)