t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/nodeProbe.ts
Julius Marminge e3c85ead63
chore(refs): sync Effect and Alchemy references to rc.115 and beta.78 (#12327)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-17 23:21:25 -07:00

28 lines
1.1 KiB
TypeScript

import { isRegisterHooksSupported } from "@/Util/Node.ts";
/**
* The real node binary tests spawn, and ITS version — not bun's emulated
* `process.versions.node`, which is what the version gates would
* consult by default. Gating on the wrong runtime made the node-launcher
* tests run (and fail with zero diagnostics) on machines whose PATH node
* is older than the version bun reports.
*/
export const nodePath = typeof Bun !== "undefined" ? Bun.which("node") : null;
export const nodeVersion: string | null = (() => {
if (nodePath === null) return null;
try {
const probe = Bun.spawnSync([nodePath, "-p", "process.versions.node"]);
const version = probe.stdout.toString().trim();
return probe.exitCode === 0 && version.length > 0 ? version : null;
} catch {
return null;
}
})();
/**
* Whether the spawned node can run alchemy's dev-mode source path: hooks
* capable implies `.ts` capable (transform flag below v26, native from v26).
*/
export const nodeSupportsDevMode =
nodeVersion !== null && isRegisterHooksSupported(nodeVersion);