commander 15.0.0-0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/command.js CHANGED
@@ -3,10 +3,11 @@ import childProcess from 'node:child_process';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import process from 'node:process';
6
+ import { stripVTControlCharacters } from 'node:util';
6
7
 
7
8
  import { Argument, humanReadableArgName } from './argument.js';
8
9
  import { CommanderError } from './error.js';
9
- import { Help, stripColor } from './help.js';
10
+ import { Help } from './help.js';
10
11
  import { Option, DualOptions } from './option.js';
11
12
  import { suggestSimilar } from './suggestSimilar.js';
12
13
 
@@ -70,7 +71,7 @@ export class Command extends EventEmitter {
70
71
  useColor() ?? (process.stdout.isTTY && process.stdout.hasColors?.()),
71
72
  getErrHasColors: () =>
72
73
  useColor() ?? (process.stderr.isTTY && process.stderr.hasColors?.()),
73
- stripColor: (str) => stripColor(str),
74
+ stripColor: (str) => stripVTControlCharacters(str),
74
75
  };
75
76
 
76
77
  this._hidden = false;
@@ -1213,7 +1214,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
1213
1214
 
1214
1215
  _executeSubCommand(subcommand, args) {
1215
1216
  args = args.slice();
1216
- let launchWithNode = false; // Use node for source targets so do not need to get permissions correct, and on Windows.
1217
1217
  const sourceExt = ['.js', '.ts', '.tsx', '.mjs', '.cjs'];
1218
1218
 
1219
1219
  function findFile(baseDir, baseName) {
@@ -1274,7 +1274,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1274
1274
  executableFile = localFile || executableFile;
1275
1275
  }
1276
1276
 
1277
- launchWithNode = sourceExt.includes(path.extname(executableFile));
1277
+ const launchWithNode = sourceExt.includes(path.extname(executableFile));
1278
1278
 
1279
1279
  let proc;
1280
1280
  if (process.platform !== 'win32') {
package/lib/help.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { humanReadableArgName } from './argument.js';
2
+ import { stripVTControlCharacters } from 'node:util';
2
3
 
3
4
  /**
4
5
  * TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS`
@@ -533,7 +534,7 @@ export class Help {
533
534
  * @returns {number}
534
535
  */
535
536
  displayWidth(str) {
536
- return stripColor(str).length;
537
+ return stripVTControlCharacters(str).length;
537
538
  }
538
539
 
539
540
  /**
@@ -728,17 +729,3 @@ export class Help {
728
729
  return wrappedLines.join('\n');
729
730
  }
730
731
  }
731
-
732
- /**
733
- * Strip style ANSI escape sequences from the string. In particular, SGR (Select Graphic Rendition) codes.
734
- *
735
- * @param {string} str
736
- * @returns {string}
737
- * @package
738
- */
739
-
740
- export function stripColor(str) {
741
- // eslint-disable-next-line no-control-regex
742
- const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
743
- return str.replace(sgrPattern, '');
744
- }
@@ -24,7 +24,7 @@ function editDistance(a, b) {
24
24
  // fill matrix
25
25
  for (let j = 1; j <= b.length; j++) {
26
26
  for (let i = 1; i <= a.length; i++) {
27
- let cost = 1;
27
+ let cost;
28
28
  if (a[i - 1] === b[j - 1]) {
29
29
  cost = 0;
30
30
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commander",
3
- "version": "15.0.0-0",
3
+ "version": "15.0.0",
4
4
  "description": "the complete solution for node.js command-line programs",
5
5
  "keywords": [
6
6
  "commander",
@@ -46,14 +46,14 @@
46
46
  }
47
47
  },
48
48
  "devDependencies": {
49
- "@eslint/js": "^9.4.0",
49
+ "@eslint/js": "^10.0.1",
50
50
  "@types/node": "^22.7.4",
51
- "eslint": "^9.17.0",
51
+ "eslint": "^10.0.2",
52
52
  "eslint-config-prettier": "^10.0.1",
53
- "globals": "^16.0.0",
53
+ "globals": "^17.3.0",
54
54
  "prettier": "^3.2.5",
55
- "tsd": "^0.31.0",
56
- "typescript": "^5.0.4",
55
+ "tsd": "^0.33.0",
56
+ "typescript": "^6.0.2",
57
57
  "typescript-eslint": "^8.12.2"
58
58
  },
59
59
  "types": "typings/index.d.ts",