// The Node version goldens and surface manifests are recorded against: the repo's // .node-version. Recording under any other Node silently re-targets the specs. import { readFileSync } from "node:fs"; export const PINNED = readFileSync(new URL("../../../.node-version", import.meta.url), "utf8").trim(); // Volta pins the same version for `node` in the repo; the two must not drift. const volta = JSON.parse(readFileSync(new URL("../../../package.json", import.meta.url), "utf8")).volta?.node; if (volta !== PINNED) throw new Error(`.node-version says ${PINNED}, package.json volta.node says ${volta}`); // process.version's source; tests import it unbundled, so it stays a literal that // bump-node.mjs moves. const { NODE_VERSION } = await import("../src/shared/platform.ts"); if (NODE_VERSION !== PINNED) throw new Error(`.node-version says ${PINNED}, src/shared/platform.ts NODE_VERSION says ${NODE_VERSION}`); // The published Node target (the kernel's own version is semver). const nibling = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).nibling?.node; if (nibling !== PINNED) throw new Error(`.node-version says ${PINNED}, package.json nibling.node says ${nibling}`); export function assertPinnedNode() { if (process.version !== `v${PINNED}`) { console.error(`golden recordings need node v${PINNED} (.node-version); this is ${process.version}`); process.exit(1); } } // The environment the oracle runs under: this shell's, minus what changes Node's output // without changing the program. FORCE_COLOR from a terminal paints util.inspect and // styleText through a pipe; NODE_OPTIONS can enable experimental builtins. const LEAKY = ["FORCE_COLOR", "NO_COLOR", "NODE_DISABLE_COLORS", "COLORTERM", "NODE_OPTIONS"]; export function oracleEnv(extra = {}) { const env = { ...process.env, ...extra }; for (const k of LEAKY) delete env[k]; return env; }