Skip to content

Commit

Permalink
fix: prevent pnpm crash with Node versions < 16.14
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts committed May 10, 2023
1 parent 0af237f commit 8fe019e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion integrations/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"typescript": "^5.0.4"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
"node": "^16.14.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ ${e.stackTraceToString()}""",
matchResult?.let {
val majorVersion = matchResult.groups[1]!!.value.toInt()
val minorVersion = matchResult.groups[2]!!.value.toInt()
// Minimum version: 14.18.0.
if (majorVersion < 14 || majorVersion == 14 && minorVersion < 18) {
throw NodeVersionError("Preview.js needs NodeJS 14.18.0+ to run, but current version is: ${nodeVersion}\n\nPlease upgrade then restart your IDE.")
// Minimum version: 16.14.0.
if (majorVersion < 16 || majorVersion == 16 && minorVersion < 14) {
throw NodeVersionError("Preview.js needs NodeJS 16.14.0+ to run, but current version is: ${nodeVersion}\n\nPlease upgrade then restart your IDE.")
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions integrations/vscode/src/start-daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,22 @@ function checkNodeVersionResult(result: ExecaReturnValue<string>):
result.exitCode !== 0 ? ` with exit code ${result.exitCode}` : "";
return {
kind: "invalid",
message: `Preview.js needs NodeJS 14.18.0+ but running \`node\` failed${withExitCode}.\n\nIs it installed? You may need to restart your IDE.\n`,
message: `Preview.js needs NodeJS 16.14.0+ but running \`node\` failed${withExitCode}.\n\nIs it installed? You may need to restart your IDE.\n`,
};
}
const nodeVersion = stripAnsi(result.stdout).split("\n").at(-1)!.trim();
const match = nodeVersion.match(/^v(\d+)\.(\d+).*$/);
const invalidVersion = {
kind: "invalid",
message: `Preview.js needs NodeJS 14.18.0+ to run.\n\nPlease upgrade then restart your IDE.`,
message: `Preview.js needs NodeJS 16.14.0+ to run.\n\nPlease upgrade then restart your IDE.`,
} as const;
if (!match) {
return invalidVersion;
}
const majorVersion = parseInt(match[1]!, 10);
const minorVersion = parseInt(match[2]!, 10);
// Minimum version: 14.18.0.
if (majorVersion < 14 || (majorVersion === 14 && minorVersion < 18)) {
// Minimum version: 16.14.0.
if (majorVersion < 16 || (majorVersion === 16 && minorVersion < 14)) {
return invalidVersion;
}

Expand Down

0 comments on commit 8fe019e

Please sign in to comment.