1import { isRegisterHooksSupported } from "@/Util/Node.ts";
2
3/**
4 * The real node binary tests spawn, and ITS version — not bun's emulated
5 * `process.versions.node`, which is what the version gates would
6 * consult by default. Gating on the wrong runtime made the node-launcher
7 * tests run (and fail with zero diagnostics) on machines whose PATH node
8 * is older than the version bun reports.
9 */
10export const nodePath = typeof Bun !== "undefined" ? Bun.which("node") : null;
11
12export const nodeVersion: string | null = (() => {
13 if (nodePath === null) return null;
14 try {
15 const probe = Bun.spawnSync([nodePath, "-p", "process.versions.node"]);
16 const version = probe.stdout.toString().trim();
17 return probe.exitCode === 0 && version.length > 0 ? version : null;
18 } catch {
19 return null;
20 }
21})();
22
23/**
24 * Whether the spawned node can run alchemy's dev-mode source path: hooks
25 * capable implies `.ts` capable (transform flag below v26, native from v26).
26 */
27export const nodeSupportsDevMode =
28 nodeVersion !== null && isRegisterHooksSupported(nodeVersion);