Skip to content

Commit bd39695

Browse files
Bump chalk from 3.0.0 to 5.4.1 (#571)
* Bump chalk from 3.0.0 to 5.4.1 Bumps [chalk](https://github.com/chalk/chalk) from 3.0.0 to 5.4.1. - [Release notes](https://github.com/chalk/chalk/releases) - [Commits](chalk/chalk@v3.0.0...v5.4.1) --- updated-dependencies: - dependency-name: chalk dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore(test): use esm chalk --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kevin Eady <[email protected]>
1 parent 2624fcd commit bd39695

File tree

2 files changed

+67
-60
lines changed

2 files changed

+67
-60
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
]
2020
},
2121
"dependencies": {
22-
"chalk": "^3.0.0",
22+
"chalk": "^5.4.1",
2323
"clang-format": "^1.4.0",
2424
"cmake-js": "^7.1.1",
2525
"semver": "^7.1.3"

test_all.js

Lines changed: 66 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const fs = require("fs");
22
const path = require("path");
33
const { execSync } = require("child_process");
4-
const chalk = require("chalk");
54
const semver = require("semver");
65

76
const examplesFolder = path.join(__dirname, "src");
@@ -21,70 +20,78 @@ function getAllExamples(pathToCheck) {
2120
return directoriesToTest;
2221
}
2322

24-
const passed = [];
25-
const failedInstalls = [];
26-
const noTest = [];
27-
const failedTests = [];
28-
for (directoryToTest of getAllExamples(examplesFolder)) {
29-
console.log(chalk.green(`testing: ${directoryToTest}`));
30-
const pkgJson = require(path.join(directoryToTest, "package.json"));
31-
if (pkgJson.engines && pkgJson.engines.node) {
32-
const currentNodeVersion = process.versions.node;
33-
const range = pkgJson.engines.node;
34-
const engineOk = semver.satisfies(currentNodeVersion, range);
35-
if (!engineOk) {
36-
console.warn(
37-
chalk.yellow(
38-
`${directoryToTest} require Node.js ${range}, current is ${currentNodeVersion}, skipping`
39-
)
40-
);
23+
const main = async () => {
24+
const { default: chalk } = await import("chalk");
25+
const passed = [];
26+
const failedInstalls = [];
27+
const noTest = [];
28+
const failedTests = [];
29+
for (directoryToTest of getAllExamples(examplesFolder)) {
30+
console.log(chalk.green(`testing: ${directoryToTest}`));
31+
const pkgJson = require(path.join(directoryToTest, "package.json"));
32+
if (pkgJson.engines && pkgJson.engines.node) {
33+
const currentNodeVersion = process.versions.node;
34+
const range = pkgJson.engines.node;
35+
const engineOk = semver.satisfies(currentNodeVersion, range);
36+
if (!engineOk) {
37+
console.warn(
38+
chalk.yellow(
39+
`${directoryToTest} require Node.js ${range}, current is ${currentNodeVersion}, skipping`
40+
)
41+
);
42+
continue;
43+
}
44+
}
45+
46+
try {
47+
const stdout = execSync("npm install", { cwd: directoryToTest });
48+
console.log(stdout.toString());
49+
} catch (err) {
50+
console.log(err);
51+
failedInstalls.push(directoryToTest);
4152
continue;
4253
}
43-
}
4454

45-
try {
46-
const stdout = execSync("npm install", { cwd: directoryToTest });
47-
console.log(stdout.toString());
48-
} catch (err) {
49-
console.log(err);
50-
failedInstalls.push(directoryToTest);
51-
continue;
52-
}
55+
let testCommand;
56+
if ("scripts" in pkgJson && "start" in pkgJson.scripts) {
57+
testCommand = "npm start";
58+
} else if ("scripts" in pkgJson && "test" in pkgJson.scripts) {
59+
testCommand = "npm test";
60+
} else if ("main" in pkgJson) {
61+
testCommand = `node ${pkgJson.main}`
62+
} else {
63+
noTest.push(directoryToTest);
64+
continue;
65+
}
5366

54-
let testCommand;
55-
if ("scripts" in pkgJson && "start" in pkgJson.scripts) {
56-
testCommand = "npm start";
57-
} else if ("scripts" in pkgJson && "test" in pkgJson.scripts) {
58-
testCommand = "npm test";
59-
} else if ("main" in pkgJson) {
60-
testCommand = `node ${pkgJson.main}`
61-
} else {
62-
noTest.push(directoryToTest);
63-
continue;
67+
try {
68+
const stdout = execSync(testCommand, { cwd: directoryToTest });
69+
console.log(stdout.toString());
70+
passed.push(directoryToTest);
71+
} catch (err) {
72+
console.log(err);
73+
failedTests.push(directoryToTest);
74+
}
6475
}
6576

66-
try {
67-
const stdout = execSync(testCommand, { cwd: directoryToTest });
68-
console.log(stdout.toString());
69-
passed.push(directoryToTest);
70-
} catch (err) {
71-
console.log(err);
72-
failedTests.push(directoryToTest);
73-
}
74-
}
77+
passed.map((dir) => console.log(chalk.green(`passed: ${dir}`)));
7578

76-
passed.map((dir) => console.log(chalk.green(`passed: ${dir}`)));
79+
if (noTest.length > 0) {
80+
console.warn(chalk.yellow("no test found:"));
81+
noTest.map((dir) => console.warn(chalk.yellow(` ${dir}`)));
82+
}
7783

78-
if (noTest.length > 0) {
79-
console.warn(chalk.yellow("no test found:"));
80-
noTest.map((dir) => console.warn(chalk.yellow(` ${dir}`)));
81-
}
84+
if (failedInstalls.length > 0) {
85+
console.error(chalk.red("failed to install:"));
86+
failedInstalls.map((dir) => console.warn(chalk.red(` ${dir}`)));
87+
}
88+
if (failedTests.length > 0) {
89+
console.error(chalk.red("failed tests:"));
90+
failedTests.map((dir) => console.warn(chalk.red(` ${dir}`)));
91+
}
92+
};
8293

83-
if (failedInstalls.length > 0) {
84-
console.error(chalk.red("failed to install:"));
85-
failedInstalls.map((dir) => console.warn(chalk.red(` ${dir}`)));
86-
}
87-
if (failedTests.length > 0) {
88-
console.error(chalk.red("failed tests:"));
89-
failedTests.map((dir) => console.warn(chalk.red(` ${dir}`)));
90-
}
94+
main().catch(e => {
95+
console.error(e);
96+
process.exitCode = 1;
97+
});

0 commit comments

Comments
 (0)