candidateDir
uses node:crypto
Where a verify of branch (main, without one) builds the tcm it checks: dist/candidates/session/…, is made one,
with a hash of it to keep it the branch's alone.)
import { createHash } from "node:crypto"; import path from "node:path"; export function candidateDir(dist: string, branch?: string): string { const b = branch || "main"; const safe = b.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^\.+/, "-"); const name = safe === b ? b : `${safe}-${createHash("sha256").update(b).digest("hex").slice(0, 6)}`; return path.join(dist, "candidates", name); }