commander
Advanced tools
Comparing version 9.5.0 to 10.0.0
@@ -370,3 +370,3 @@ const { humanReadableArgName } = require('./argument.js'); | ||
if (commandDescription.length > 0) { | ||
output = output.concat([commandDescription, '']); | ||
output = output.concat([helper.wrap(commandDescription, helpWidth, 0), '']); | ||
} | ||
@@ -440,5 +440,7 @@ | ||
wrap(str, width, indent, minColumnWidth = 40) { | ||
// Detect manually wrapped and indented strings by searching for line breaks | ||
// followed by multiple spaces/tabs. | ||
if (str.match(/[\n]\s+/)) return str; | ||
// Full \s characters, minus the linefeeds. | ||
const indents = ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff'; | ||
// Detect manually wrapped and indented strings by searching for line break followed by spaces. | ||
const manualIndent = new RegExp(`[\\n][${indents}]+`); | ||
if (str.match(manualIndent)) return str; | ||
// Do not wrap if not enough room for a wrapped column of text (as could end up with a word per line). | ||
@@ -449,12 +451,13 @@ const columnWidth = width - indent; | ||
const leadingStr = str.slice(0, indent); | ||
const columnText = str.slice(indent); | ||
const columnText = str.slice(indent).replace('\r\n', '\n'); | ||
const indentString = ' '.repeat(indent); | ||
const regex = new RegExp('.{1,' + (columnWidth - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g'); | ||
const zeroWidthSpace = '\u200B'; | ||
const breaks = `\\s${zeroWidthSpace}`; | ||
// Match line end (so empty lines don't collapse), | ||
// or as much text as will fit in column, or excess text up to first break. | ||
const regex = new RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g'); | ||
const lines = columnText.match(regex) || []; | ||
return leadingStr + lines.map((line, i) => { | ||
if (line.slice(-1) === '\n') { | ||
line = line.slice(0, line.length - 1); | ||
} | ||
return ((i > 0) ? indentString : '') + line.trimRight(); | ||
if (line === '\n') return ''; // preserve empty lines | ||
return ((i > 0) ? indentString : '') + line.trimEnd(); | ||
}).join('\n'); | ||
@@ -461,0 +464,0 @@ } |
{ | ||
"name": "commander", | ||
"version": "9.5.0", | ||
"version": "10.0.0", | ||
"description": "the complete solution for node.js command-line programs", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
"test": "jest && npm run test-typings", | ||
"test-esm": "node --experimental-modules ./tests/esm-imports-test.mjs", | ||
"test-esm": "node ./tests/esm-imports-test.mjs", | ||
"test-typings": "tsd", | ||
@@ -50,17 +50,17 @@ "typescript-checkJS": "tsc --allowJS --checkJS index.js lib/*.js --noEmit", | ||
"devDependencies": { | ||
"@types/jest": "^28.1.4", | ||
"@types/node": "^16.11.15", | ||
"@typescript-eslint/eslint-plugin": "^5.30.6", | ||
"@typescript-eslint/parser": "^5.30.6", | ||
"eslint": "^8.19.0", | ||
"@types/jest": "^29.2.4", | ||
"@types/node": "^18.11.18", | ||
"@typescript-eslint/eslint-plugin": "^5.47.1", | ||
"@typescript-eslint/parser": "^5.47.1", | ||
"eslint": "^8.30.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-config-standard-with-typescript": "^22.0.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint-plugin-jest": "^26.5.3", | ||
"eslint-plugin-n": "^15.2.4", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"jest": "^28.1.2", | ||
"ts-jest": "^28.0.5", | ||
"tsd": "^0.22.0", | ||
"typescript": "^4.7.4" | ||
"eslint-config-standard-with-typescript": "^24.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^27.1.7", | ||
"eslint-plugin-n": "^15.6.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"jest": "^29.3.1", | ||
"ts-jest": "^29.0.3", | ||
"tsd": "^0.25.0", | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -79,5 +79,5 @@ "types": "typings/index.d.ts", | ||
"engines": { | ||
"node": "^12.20.0 || >=14" | ||
"node": ">=14" | ||
}, | ||
"support": true | ||
} |
@@ -1120,3 +1120,3 @@ # Commander.js | ||
The current version of Commander is fully supported on Long Term Support versions of Node.js, and requires at least v12.20.0. | ||
The current version of Commander is fully supported on Long Term Support versions of Node.js, and requires at least v14. | ||
(For older versions of Node.js, use an older version of Commander.) | ||
@@ -1123,0 +1123,0 @@ |
@@ -278,5 +278,3 @@ // Type definitions for commander | ||
export interface OptionValues { | ||
[key: string]: any; | ||
} | ||
export type OptionValues = Record<string, any>; | ||
@@ -286,3 +284,4 @@ export class Command { | ||
processedArgs: any[]; | ||
commands: Command[]; | ||
readonly commands: readonly Command[]; | ||
readonly options: readonly Option[]; | ||
parent: Command | null; | ||
@@ -729,3 +728,3 @@ | ||
/** @deprecated since v8, instead use .argument to add command argument with description */ | ||
description(str: string, argsDescription: {[argName: string]: string}): this; | ||
description(str: string, argsDescription: Record<string, string>): this; | ||
/** | ||
@@ -732,0 +731,0 @@ * Get the description. |
173653
3736