Remove please-upgrade-node (#19697)
This commit is contained in:
1 parent
e79f6b74da
commit
b2117a8065
8 files changed
+117
-35
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { PRODUCTION_MINIMAL_NODE_JS_VERSION } from "../../../scripts/utilities/index.js";
|
||||
|
||||
const minimalVersion =
|
||||
process.env.NODE_ENV === "production"
|
||||
? Number(PRODUCTION_MINIMAL_NODE_JS_VERSION)
|
||||
: // Dev version
|
||||
22;
|
||||
|
||||
describe("Check Node.js version", () => {
|
||||
for (const version of [
|
||||
"0.10.0",
|
||||
"0.12.0",
|
||||
...(function* () {
|
||||
for (let major = 4; major < minimalVersion; major++) {
|
||||
if (major >= 26 || major % 2 === 0) {
|
||||
yield `${major}.0.0`;
|
||||
}
|
||||
}
|
||||
})(),
|
||||
]) {
|
||||
test(version, async () => {
|
||||
await expect(() =>
|
||||
runCli("cli/", ["--version"], { mockNodeVersion: version }),
|
||||
).rejects.toThrow(
|
||||
/Prettier requires at least version \d+ of Node.js, please upgrade!/,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
for (const version of [`${minimalVersion}.0.0`, "current"]) {
|
||||
test(version, async () => {
|
||||
const { stdout } = await runCli("cli/", ["--version"], {
|
||||
mockNodeVersion: version === "current" ? undefined : version,
|
||||
});
|
||||
expect(typeof stdout).toBe("string");
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -19,6 +19,7 @@ const replaceAll = (text, find, replacement) =>
|
||||
text.replaceAll
|
||||
? text.replaceAll(find, replacement)
|
||||
: text.split(find).join(replacement);
|
||||
const originalNodeVersion = process.versions.node;
|
||||
|
||||
async function getApiMockable() {
|
||||
const prettier = await import(url.pathToFileURL(prettierMainEntry));
|
||||
@@ -86,9 +87,22 @@ async function mockImplementations(options) {
|
||||
});
|
||||
}
|
||||
|
||||
let nodeVersionMocked = false;
|
||||
async function run(options) {
|
||||
await mockImplementations(options);
|
||||
|
||||
if (!nodeVersionMocked) {
|
||||
nodeVersionMocked = true;
|
||||
Object.defineProperty(process.versions, "node", {
|
||||
get value() {
|
||||
return options.mockNodeVersion || originalNodeVersion;
|
||||
},
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
|
||||
const { __promise: promise } = await import(
|
||||
url.pathToFileURL(prettierCliEntry)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user