Files
explore/scripts/clean.mjs
b10fba99e6 Initial commit
Co-authored-by: Brent Vatne <[email protected]>
Co-authored-by: Szymon Dziedzic <[email protected]>
2026-10-14 14:10:07 -07:00

16 lines
607 B
JavaScript

import { readdir, rm } from "node:fs/promises";
import { dirname, resolve } from "node:path";
const workspace = process.cwd();
const output = resolve(workspace, "dist");
if (dirname(output) !== workspace) {
throw new Error(`Refusing to clean unexpected output path: ${output}`);
}
// The hosted Viewer export is built separately (npm run build:hosting:preview) and takes minutes; a CLI rebuild keeps it.
const keep = new Set(["hosting-preview"]);
for (const entry of await readdir(output).catch(() => [])) {
if (!keep.has(entry)) await rm(resolve(output, entry), { recursive: true, force: true });
}