Skip to content
Myr

Replace use of arguments.length (#1235)

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

authored by John Gee · committed by GitHub · parent b5d95ee · Browse files · 1 file+17 added−15 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+17 added−15 removed

  • other:+17 added−15 removed

1 file+17 added−15 removed

modified:index.js+17 added-15 removed
580 unmodified lines
581 * for unknown options.582 * @api public583 */584 allowUnknownOption(arg) {585 this._allowUnknownOption = arguments.length === 0 || arg;585 this._allowUnknownOption = (arg === undefined) || arg;586 return this;587 };588589 /**
591 unmodified lines
1181 * @api public1182 */11831184 version(str, flags, description) {1185 if (arguments.length === 0) return this._version;1185 if (str === undefined) return this._version;1186 this._version = str;1187 flags = flags || '-V, --version';1188 description = description || 'output the version number';1189 const versionOption = new Option(flags, description);
15 unmodified lines
1205 * @api public1206 */12071208 description(str, argsDescription) {1209 if (arguments.length === 0) return this._description;1209 if (str === undefined && argsDescription === undefined) return this._description;1210 this._description = str;1211 this._argsDescription = argsDescription;1212 return this;1213 };
6 unmodified lines
1220 * @api public1221 */12221223 alias(alias) {1224 if (alias === undefined) return this._alias;12251226 let command = this;1225 if (this.commands.length !== 0) {1227 if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {1228 // assume adding alias for last added executable subcommand, rather than this1229 command = this.commands[this.commands.length - 1];1230 }12311229 if (arguments.length === 0) return command._alias;12301232 if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');12331234 command._alias = alias;1235 return this;
7 unmodified lines
1243 * @api public1244 */12451246 usage(str) {1246 const args = this._args.map((arg) => {1247 return humanReadableArgName(arg);1248 });1247 if (str === undefined) {1248 if (this._usage) return this._usage;12491250 const args = this._args.map((arg) => {1251 return humanReadableArgName(arg);1252 });1250 const usage = '[options]' +1251 (this.commands.length ? ' [command]' : '') +1252 (this._args.length ? ' ' + args.join(' ') : '');1253 return '[options]' +1254 (this.commands.length ? ' [command]' : '') +1255 (this._args.length ? ' ' + args.join(' ') : '');1256 }12571254 if (arguments.length === 0) return this._usage || usage;1258 this._usage = str;12561259 return this;1260 };12611262 /**
4 unmodified lines
1267 * @api public1268 */12691270 name(str) {1269 if (arguments.length === 0) return this._name;1271 if (str === undefined) return this._name;1272 this._name = str;1273 return this;1274 };1275
444 unmodified lines