返回 CodeWhale
vitest.global-setup.ts
根目录 / web / vitest.global-setup.ts
1 import { execFileSync } from "node:child_process";
2 import { fileURLToPath } from "node:url";
3
4 /**
5 * Derive the untracked build inputs before any test file imports them.
6 * `lib/changelog.generated.ts`, `lib/install-guide.generated.ts` and
7 * `data/agent-docs.generated.json` are not committed (see web/.gitignore), so
8 * a bare `vitest run` on a fresh checkout must write them from CHANGELOG.md,
9 * docs/INSTALL.md and the registered docs sources first. Facts stay out
10 * of this list on purpose: `facts.generated.ts` is committed, and rewriting it
11 * here would hide the drift `npm run check:facts` exists to catch.
12 */
13 export default function setup() {
14 for (const script of ["derive-changelog.mjs", "derive-install.mjs", "derive-agent-docs.mjs"]) {
15 execFileSync(process.execPath, [fileURLToPath(new URL(`./scripts/${script}`, import.meta.url))], {
16 stdio: "inherit",
17 });
18 }
19 }
20
20 lines TYPESCRIPT