(minimumMajor: number, minimumMinor: number)
| 4 | * This function is used by the dev CLI to make sure that the runtime is compatible |
| 5 | */ |
| 6 | export function runtimeCheck(minimumMajor: number, minimumMinor: number) { |
| 7 | // Check if the runtime is Node.js |
| 8 | if (typeof process === "undefined") { |
| 9 | throw "The dev CLI can only be run in a Node.js compatible environment"; |
| 10 | } |
| 11 | |
| 12 | // Check if the runtime version is compatible |
| 13 | const [major = 0, minor = 0] = process.versions.node.split(".").map(Number); |
| 14 | |
| 15 | const isBun = typeof process.versions.bun === "string"; |
| 16 | |
| 17 | if (major < minimumMajor || (major === minimumMajor && minor < minimumMinor)) { |
| 18 | if (isBun) { |
| 19 | throw `The dev CLI requires at least Node.js ${minimumMajor}.${minimumMinor}. You are running Bun ${process.versions.bun}, which is compatible with Node.js ${process.versions.node}`; |
| 20 | } else { |
| 21 | throw `The dev CLI requires at least Node.js ${minimumMajor}.${minimumMinor}. You are running Node.js ${process.versions.node}`; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | logger.debug( |
| 26 | `Node.js version: ${process.versions.node}${isBun ? ` (Bun ${process.versions.bun})` : ""}` |
| 27 | ); |
| 28 | } |
no test coverage detected
searching dependent graphs…