diff --git a/lib/code-excerpt.js b/lib/code-excerpt.js index c3ac11c6c..ca9ab0586 100644 --- a/lib/code-excerpt.js +++ b/lib/code-excerpt.js @@ -2,7 +2,6 @@ import fs from 'node:fs'; import truncate from 'cli-truncate'; import codeExcerpt from 'code-excerpt'; -import equalLength from 'equal-length'; import {chalk} from './chalk.js'; @@ -34,20 +33,15 @@ export default function exceptCode(source, options = {}) { value: truncate(item.value, maxWidth - String(line).length - 5), })); - const joinedLines = lines.map(line => line.value).join('\n'); - const extendedLines = equalLength(joinedLines).split('\n'); + const extendedWidth = Math.max(...lines.map(item => item.value.length)); return lines - .map((item, index) => ({ - line: item.line, - value: extendedLines[index], - })) .map(item => { const isErrorSource = item.line === line; const lineNumber = formatLineNumber(item.line, line) + ':'; const coloredLineNumber = isErrorSource ? lineNumber : chalk.grey(lineNumber); - const result = ` ${coloredLineNumber} ${item.value}`; + const result = ` ${coloredLineNumber} ${item.value.padEnd(extendedWidth)}`; return isErrorSource ? chalk.bgRed(result) : result; }) diff --git a/package-lock.json b/package-lock.json index 4f8f0ec1c..6a26fc643 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,6 @@ "debug": "^4.3.2", "del": "^6.0.0", "emittery": "^0.10.0", - "equal-length": "^1.0.1", "figures": "^4.0.0", "globby": "^12.0.2", "ignore-by-default": "^2.0.0", @@ -3532,6 +3531,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/equal-length/-/equal-length-1.0.1.tgz", "integrity": "sha1-IcoRLUirJLTh5//A5TOdMf38J0w=", + "dev": true, "engines": { "node": ">=4" } diff --git a/package.json b/package.json index 52d9abb4f..540775fed 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,6 @@ "debug": "^4.3.2", "del": "^6.0.0", "emittery": "^0.10.0", - "equal-length": "^1.0.1", "figures": "^4.0.0", "globby": "^12.0.2", "ignore-by-default": "^2.0.0",