Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/argument.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Argument {
break;
}

if (this._name.length > 3 && this._name.slice(-3) === '...') {
if (this._name.length > 3 && this._name.endsWith('...')) {
this.variadic = true;
this._name = this._name.slice(0, -3);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
const args = argv.slice();

function maybeOption(arg) {
return arg.length > 1 && arg[0] === '-';
return arg.length > 1 && arg.startsWith('-');
}

const negativeNumberArg = (arg) => {
Expand Down Expand Up @@ -1816,7 +1816,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
}

// Look for combo options following single dash, eat first one if known.
if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {
if (arg.length > 2 && arg.startsWith('-') && !arg.startsWith('--')) {
const option = this._findOption(`-${arg[1]}`);
if (option) {
if (
Expand Down
4 changes: 2 additions & 2 deletions lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class Help {
.map((word) => {
if (word === '[options]') return this.styleOptionText(word);
if (word === '[command]') return this.styleSubcommandText(word);
if (word[0] === '[' || word[0] === '<')
if (word.startsWith('[') || word.startsWith('<'))
return this.styleArgumentText(word);
return this.styleCommandText(word); // Restrict to initial words?
})
Expand Down Expand Up @@ -585,7 +585,7 @@ class Help {
.split(' ')
.map((word) => {
if (word === '[options]') return this.styleOptionText(word);
if (word[0] === '[' || word[0] === '<')
if (word.startsWith('[') || word.startsWith('<'))
return this.styleArgumentText(word);
return this.styleSubcommandText(word); // Restrict to initial words?
})
Expand Down