Skip to content

Commit ac8db3a

Browse files
aweebitabetomo
authored andcommitted
Refactor _checkForBrokenPassThrough() to make it instance-aware
1 parent ec1942d commit ac8db3a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/command.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class Command extends EventEmitter {
272272

273273
this.commands.push(cmd);
274274
cmd.parent = this;
275-
this._checkForBrokenPassThrough(cmd, this);
275+
cmd._checkForBrokenPassThrough();
276276

277277
return this;
278278
}
@@ -737,19 +737,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
737737
*/
738738
passThroughOptions(passThrough = true) {
739739
this._passThroughOptions = !!passThrough;
740-
this._checkForBrokenPassThrough(this, this.parent);
740+
this._checkForBrokenPassThrough();
741741
return this;
742742
}
743743

744744
/**
745-
* @param {Command} command
746-
* @param {Command | null} parent
747745
* @api private
748746
*/
749747

750-
_checkForBrokenPassThrough(command, parent) {
751-
if (parent && command._passThroughOptions && !parent._enablePositionalOptions) {
752-
throw new Error(`passThroughOptions cannot be used for '${command._name}' without turning on enablePositionalOptions for parent command(s)`);
748+
_checkForBrokenPassThrough() {
749+
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
750+
throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
753751
}
754752
}
755753

0 commit comments

Comments
 (0)