import { spawnSync } from "node:child_process"; const out = spawnSync("git", ["diff", "--cached", "--name-only", "--diff-filter=ACM"], { encoding: "utf8" }); if (out.status !== 0) process.exit(out.status ?? 1); const files = out.stdout .split("\n") .map((s) => s.trim()) .filter(Boolean) .filter((f) => /\.(ts|tsx)$/.test(f)); if (files.length === 0) process.exit(0); const vitest = spawnSync( "npx", ["vitest", "related", ...files, "--run", "--project", "unit", "--passWithNoTests"], { stdio: "inherit", shell: process.platform === "win32" } ); process.exit(vitest.status === 0 ? 0 : vitest.status ?? 1);