21 lines
1.1 KiB
JavaScript
21 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
// Expansion Drop must touch only content: fail if any changed path is under an engine dir.
|
|
import { readFileSync } from "node:fs";
|
|
import { execFileSync } from "node:child_process";
|
|
import { join, posix } from "node:path";
|
|
import { fail } from "./lib.mjs";
|
|
|
|
const [ws, baseRef] = process.argv.slice(2);
|
|
if (!ws || !baseRef) fail("usage: expansion-check.mjs <workspaceDir> <baseRef>");
|
|
|
|
const git = (...a) => execFileSync("git", a, { cwd: ws, encoding: "utf8" }).split("\n").filter(Boolean);
|
|
const cfg = JSON.parse(readFileSync(join(ws, ".course.json"), "utf8"));
|
|
const changed = new Set([
|
|
...git("diff", "--name-only", "--relative", baseRef),
|
|
...git("ls-files", "--others", "--exclude-standard"),
|
|
]);
|
|
const engine = (cfg.engineDirs || []).map((d) => posix.normalize(d).replace(/\/$/, ""));
|
|
const bad = [...changed].filter((p) => engine.some((d) => p === d || p.startsWith(d + "/")));
|
|
if (bad.length) fail("expansion-check: engine changed during Expansion Drop\n" + bad.map((p) => " " + p).join("\n"));
|
|
console.log(`expansion-check: ok (${changed.size} changed, none in engine)`);
|