Skip to content

Commit

Permalink
Merge pull request #1709 from prosopo/version-check
Browse files Browse the repository at this point in the history
Add check for node version
  • Loading branch information
l0r1s authored Jan 30, 2024
2 parents ed9dbd0 + db35104 commit c8eb540
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions javascript/packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { convert } from "./actions/convert";
import { setup } from "./actions/setup";
import { spawn } from "./actions/spawn";
import { test } from "./actions/test";
import { checkNodeVersion } from "./versionCheck";

const debug = require("debug")("zombie-cli");

Expand All @@ -18,6 +19,8 @@ const setGlobalNetwork = (globalNetwork: Network) => {
network = globalNetwork;
};

checkNodeVersion();

async function handleTermination(userInterrupted = false) {
process.env.terminating = "1";
if (network && !alreadyTryToStop) {
Expand Down
24 changes: 24 additions & 0 deletions javascript/packages/cli/src/versionCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { decorators } from "@zombienet/utils";

export const checkNodeVersion = () => {
const nodeVersion = process.versions.node;
const requiredNodeVersion = getPackageNodeVersion();
if (
parseInt(nodeVersion.split(".")[0]) <
parseInt(requiredNodeVersion.split(".")[0])
) {
console.error(
`\n${decorators.red("Error: ")} \t ${decorators.bright(
`Node version ${nodeVersion} is not supported. Please update to Node ${requiredNodeVersion} or above.`,
)}\n`,
);
process.exit(1);
}
};

const getPackageNodeVersion = () => {
const {
engines: { node },
} = require("../package.json");
return node.replace(/>=\s*/, "");
};

0 comments on commit c8eb540

Please sign in to comment.