Skip to content

Commit 777dd6f

Browse files
committed
Use chalk library for colorized output in analyze-field-access script
1 parent 65b9dcd commit 777dd6f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"devDependencies": {
3939
"@types/jest": "^29.2.5",
40+
"chalk": "^4.3.0",
4041
"dedent-js": "^1.0.1",
4142
"jest": "^29.7.0",
4243
"ts-jest": "^29.1.1",

scripts/analyze-field-access.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as ts from "typescript";
2+
import chalk from "chalk";
23

34
/**
45
* This script analyzes the syntax map files in src/syntax/ dir
@@ -25,8 +26,9 @@ for (const sourceFile of program.getSourceFiles()) {
2526
}
2627

2728
if (errors.length > 0) {
28-
console.log(`Found ${errors.length} problems:\n`);
29+
console.log(chalk.red(`Found ${errors.length} problems:\n`));
2930
console.error(errors.join("\n\n"));
31+
console.log();
3032
process.exit(1);
3133
}
3234

@@ -84,9 +86,13 @@ function analyzeObjectProperty(node: ts.Node, sourceFile: ts.SourceFile) {
8486
if (missingFields.length > 0) {
8587
errors.push(
8688
[
87-
`In file: ${sourceFile.fileName.replace(/.*\//, "src/syntax/")}`,
88-
`Unused fields: ${missingFields.join(", ")}`,
89-
node.getText(sourceFile),
89+
chalk.yellow(
90+
`${"In file:"} ${chalk.bold(
91+
sourceFile.fileName.replace(/.*\//, "src/syntax/"),
92+
)}`,
93+
),
94+
chalk.red(`Unused fields: ${chalk.bold(missingFields.join(", "))}`),
95+
chalk.blackBright(node.getText(sourceFile)),
9096
].join("\n"),
9197
);
9298
}

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ chalk@^2.0.0:
937937
escape-string-regexp "^1.0.5"
938938
supports-color "^5.3.0"
939939

940-
chalk@^4.0.0:
940+
chalk@^4.0.0, chalk@^4.3.0:
941941
version "4.1.2"
942942
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
943943
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==

0 commit comments

Comments
 (0)