diff --git a/lib/command.js b/lib/command.js index 65559112a..e4b5d1699 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._checkForBrokenPassThrough(cmd, this); + cmd._checkForBrokenPassThrough(); return this; } @@ -737,19 +737,17 @@ Expecting one of '${allowedValues.join("', '")}'`); */ passThroughOptions(passThrough = true) { this._passThroughOptions = !!passThrough; - this._checkForBrokenPassThrough(this, this.parent); + this._checkForBrokenPassThrough(); return this; } /** - * @param {Command} command - * @param {Command | null} parent * @api private */ - _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(s)`); + _checkForBrokenPassThrough() { + if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) { + throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`); } }