// scripts/purge-dist-dev-whoami.mjs import fs from "node:fs/promises"; import path from "node:path"; const CWD = process.cwd(); const targetDir = path.join(CWD, "dist", "_auth", "whoami"); const targetIndex = path.join(CWD, "dist", "_auth", "whoami", "index.html"); // Purge idempotente (force=true => pas d'erreur si absent) async function rmSafe(p) { try { await fs.rm(p, { recursive: true, force: true }); return true; } catch { return false; } } async function main() { const removedIndex = await rmSafe(targetIndex); const removedDir = await rmSafe(targetDir); // Optionnel: si dist/_auth devient vide, on laisse tel quel (pas besoin de toucher) const any = removedIndex || removedDir; console.log(`✅ purge-dist-dev-whoami: ${any ? "purged" : "nothing to purge"}`); } main().catch((e) => { console.error("❌ purge-dist-dev-whoami failed:", e); process.exit(1); });