Refine prepare-test-for-legacy-nodejs script (#17591)
This commit is contained in:
1 parent
d6845a30d5
commit
948a54bdbf
2 files changed
+19
-8
No files matched your search
@@ -1,15 +1,26 @@
|
||||
import fs from "node:fs";
|
||||
|
||||
const nodejsMajorVersion = Number(process.versions.node.split(".")[0]);
|
||||
const packageJsonFile = new URL("../package.json", import.meta.url);
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile));
|
||||
|
||||
const jestVersion =
|
||||
nodejsMajorVersion === 14
|
||||
? // `jest@30.0.0-alpha.2` is the last version that supports Node.js v14
|
||||
"30.0.0-alpha.2"
|
||||
: // `jest@30.0.0-alpha.7` is the last version that supports Node.js v16
|
||||
"30.0.0-alpha.7";
|
||||
const argv = process.argv.slice(2);
|
||||
const nodeVersion = Number(argv[1]);
|
||||
|
||||
if (argv[0] !== "--node-version" || !Number.isInteger(nodeVersion)) {
|
||||
throw new Error("Expect `--node-version` argument.");
|
||||
}
|
||||
|
||||
let jestVersion;
|
||||
|
||||
if (nodeVersion === 14) {
|
||||
// `jest@30.0.0-alpha.2` is the last version that supports Node.js v14
|
||||
jestVersion = "30.0.0-alpha.2";
|
||||
} else if (nodeVersion === 16) {
|
||||
// `jest@30.0.0-alpha.7` is the last version that supports Node.js v16
|
||||
jestVersion = "30.0.0-alpha.7";
|
||||
} else {
|
||||
throw new Error("Unexpected `--node-version`.");
|
||||
}
|
||||
|
||||
// Script to get dependencies
|
||||
// console.log(
|
||||
|
||||
Reference in new issue
Block a user