Skip to content
Myr

Add missing checks for passThroughOptions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Wee Bit · committed by Abe Tomoaki · parent d038570 · Browse files · 1 file+18 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−3 removed

  • other:+18 added−3 removed

1 file+18 added−3 removed

modified:lib/command.js+18 added-3 removed
270 unmodified lines
271 if (opts.noHelp || opts.hidden) cmd._hidden = true; // modifying passed command due to existing implementation272273 this.commands.push(cmd);274 cmd.parent = this;275 this._checkForIllegalPassThroughOptions(cmd, this);276277 return this;278 }279280 /**
441 unmodified lines
722 * @param {Boolean} [positional=true]723 */724 enablePositionalOptions(positional = true) {725 this._enablePositionalOptions = !!positional;726 this.commands.forEach((command) => {727 this._checkForIllegalPassThroughOptions(command, this);728 });729 return this;730 }731732 /**
6 unmodified lines
739 * for unknown options.740 */741 passThroughOptions(passThrough = true) {742 this._passThroughOptions = !!passThrough;738 if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {739 throw new Error('passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)');740 }743 this._checkForIllegalPassThroughOptions(this, this.parent);744 return this;745 }746747 /**748 * @param {Command} command749 * @param {Command | null} parent750 * @api private751 */752753 _checkForIllegalPassThroughOptions(command, parent) {754 if (parent && command._passThroughOptions && !parent._enablePositionalOptions) {755 throw new Error(`passThroughOptions cannot be used for '${command._name}' without turning on enablePositionalOptions for parent command${parent._name ? ` '${parent._name}'` : ''}`);756 }757 }758759 /**760 * Whether to store option values as properties on command object,761 * or store separately (specify false). In both cases the option values can be accessed using .opts().762 *763 * @param {boolean} [storeAsProperties=true]
1448 unmodified lines