Skip to content

Commit

Permalink
refactor: replace strip-ansi with native module (#18982)
Browse files Browse the repository at this point in the history
chore(deps): replace strip-ansi with native module
  • Loading branch information
Namchee authored Oct 3, 2024
1 parent b827029 commit d0a5414
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ function getFirstVersionOfDeletion(filePath) {
* @returns {Object} Output from each formatter
*/
function getFormatterResults() {
const stripAnsi = require("strip-ansi");
const util = require("node:util");
const formattersMetadata = require("./lib/cli-engine/formatters/formatters-meta.json");

const formatterFiles = fs.readdirSync("./lib/cli-engine/formatters/").filter(fileName => !fileName.includes("formatters-meta.json")),
Expand Down Expand Up @@ -513,7 +513,7 @@ function getFormatterResults() {
);

data.formatterResults[name] = {
result: stripAnsi(formattedOutput),
result: util.stripVTControlCharacters(formattedOutput),
description: formattersMetadata.find(formatter => formatter.name === name).description
};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/cli-engine/formatters/stylish.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"use strict";

const chalk = require("chalk"),
stripAnsi = require("strip-ansi"),
util = require("node:util"),
table = require("text-table");

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -72,7 +72,7 @@ module.exports = function(results) {
{
align: ["", "r", "l"],
stringLength(str) {
return stripAnsi(str).length;
return util.stripVTControlCharacters(str).length;
}
}
).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join("\n")}\n\n`;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"minimatch": "^3.1.2",
"natural-compare": "^1.4.0",
"optionator": "^0.9.3",
"strip-ansi": "^6.0.1",
"text-table": "^0.2.0"
},
"devDependencies": {
Expand Down

0 comments on commit d0a5414

Please sign in to comment.