diff --git a/lib/command.js b/lib/command.js index e01586a1d..d190512ed 100644 --- a/lib/command.js +++ b/lib/command.js @@ -272,7 +272,7 @@ class Command extends EventEmitter { this.commands.push(cmd); cmd.parent = this; - this._checkForIllegalPassThroughOptions(cmd, this); + this._checkForBrokenPassThrough(cmd, this); return this; } @@ -737,7 +737,7 @@ Expecting one of '${allowedValues.join("', '")}'`); */ passThroughOptions(passThrough = true) { this._passThroughOptions = !!passThrough; - this._checkForIllegalPassThroughOptions(this, this.parent); + this._checkForBrokenPassThrough(this, this.parent); return this; } @@ -747,7 +747,7 @@ Expecting one of '${allowedValues.join("', '")}'`); * @api private */ - _checkForIllegalPassThroughOptions(command, parent) { + _checkForBrokenPassThrough(command, parent) { if (parent && command._passThroughOptions && !parent._enablePositionalOptions) { throw new Error(`passThroughOptions cannot be used for '${command._name}' without turning on enablePositionalOptions for parent command${parent._name ? ` '${parent._name}'` : ''}`); } diff --git a/tests/command.positionalOptions.test.js b/tests/command.positionalOptions.test.js index 73dd7a877..82011e136 100644 --- a/tests/command.positionalOptions.test.js +++ b/tests/command.positionalOptions.test.js @@ -362,7 +362,7 @@ describe('program with action handler and positionalOptions and subcommand', () // ------------------------------------------------------------------------------ -describe('illegal passThroughOptions', () => { +describe('broken passThrough', () => { test('when program not positional and turn on passThroughOptions in subcommand then error', () => { const program = new commander.Command(); const sub = program.command('sub');