Skip to content

Commit e26aed9

Browse files
[refactor] Replace ansis with built-in function util.styleText (#3793)
> What does the pull request accomplish? One external dependency less.
1 parent 85b4ece commit e26aed9

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ planned for 2025-07-01
3131
- Switch Stylelint config to flat format and simplify Stylelint scripts
3232
- [workflow] Replace Node.js version v23 with v24 (#3770)
3333
- [refactor] Replace deprecated constants `fs.F_OK` and `fs.R_OK` (#3789)
34+
- [refactor] Replace `ansis` with built-in function `util.styleText`
3435

3536
### Fixed
3637

js/check_config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require("node:path");
22
const fs = require("node:fs");
3+
const { styleText } = require("node:util");
34
const Ajv = require("ajv");
4-
const colors = require("ansis");
55
const globals = require("globals");
66
const { Linter } = require("eslint");
77

@@ -61,7 +61,7 @@ function checkConfigFile () {
6161
);
6262

6363
if (errors.length === 0) {
64-
Log.info(colors.green("Your configuration file doesn't contain syntax errors :)"));
64+
Log.info(styleText("green", "Your configuration file doesn't contain syntax errors :)"));
6565
validateModulePositions(configFileName);
6666
} else {
6767
let errorMessage = "Your configuration file contains syntax errors :(";
@@ -112,7 +112,7 @@ function validateModulePositions (configFileName) {
112112

113113
const valid = validate(data);
114114
if (valid) {
115-
Log.info(colors.green("Your modules structure configuration doesn't contain errors :)"));
115+
Log.info(styleText("green", "Your modules structure configuration doesn't contain errors :)"));
116116
} else {
117117
const module = validate.errors[0].instancePath.split("/")[2];
118118
const position = validate.errors[0].instancePath.split("/")[3];

js/logger.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(function (root, factory) {
33
if (typeof exports === "object") {
44
if (process.env.JEST_WORKER_ID === undefined) {
5-
const colors = require("ansis");
5+
const { styleText } = require("node:util");
66

77
// add timestamps in front of log messages
88
require("console-stamp")(console, {
@@ -12,25 +12,25 @@
1212
const { method, defaultTokens } = arg;
1313
let label = defaultTokens.label(arg);
1414
if (method === "error") {
15-
label = colors.red(label);
15+
label = styleText("red", label);
1616
} else if (method === "warn") {
17-
label = colors.yellow(label);
17+
label = styleText("yellow", label);
1818
} else if (method === "debug") {
19-
label = colors.bgBlue(label);
19+
label = styleText("bgBlue", label);
2020
} else if (method === "info") {
21-
label = colors.blue(label);
21+
label = styleText("blue", label);
2222
}
2323
return label;
2424
},
2525
msg: (arg) => {
2626
const { method, defaultTokens } = arg;
2727
let msg = defaultTokens.msg(arg);
2828
if (method === "error") {
29-
msg = colors.red(msg);
29+
msg = styleText("red", msg);
3030
} else if (method === "warn") {
31-
msg = colors.yellow(msg);
31+
msg = styleText("yellow", msg);
3232
} else if (method === "info") {
33-
msg = colors.blue(msg);
33+
msg = styleText("blue", msg);
3434
}
3535
return msg;
3636
}

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
},
6464
"dependencies": {
6565
"ajv": "^8.17.1",
66-
"ansis": "^4.0.0",
6766
"console-stamp": "^3.1.2",
6867
"envsub": "^4.1.0",
6968
"eslint": "^9.27.0",

0 commit comments

Comments
 (0)