// export/out AFTER A RUN (release 18 S4). A site's or the hub's build stage // points the checkout's `export/out` at the bundle it built — in this suite a // bundle under `editor/test-transcripts/.export-builds//out`, which the // next resetData deletes. A link left dangling there makes a bare `next build` // of the export app fail on `stat export/out` (ENOENT) — the export build gate, // e2e:2origin. So the suite removes the link it made, at teardown and again at // setup (a killed run never tears down). Only a link INTO test-transcripts is // touched: a real directory, or a link to a real bundle, is the checkout's. import { lstat, readlink, rm } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; const editorDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const exportOut = path.resolve(editorDir, "..", "export", "out"); const testTranscripts = path.join(editorDir, "test-transcripts"); export async function dropTestExportOutLink(when: "setup" | "teardown"): Promise { const st = await lstat(exportOut).catch(() => null); if (!st?.isSymbolicLink()) return; const target = path.resolve(path.dirname(exportOut), await readlink(exportOut)); if (target !== testTranscripts && !target.startsWith(`${testTranscripts}${path.sep}`)) return; await rm(exportOut, { force: true }); console.log(`[e2e ${when}] removed export/out → ${path.relative(editorDir, target)} (a test bundle)`); }