UNPKG

rollup-plugin-delete

Version:
23 lines (21 loc) 654 B
import { deleteAsync } from "del"; function del(options = {}) { const { hook = "buildStart", runOnce = false, targets = [], verbose = false, ...delOptions } = options; let deleted = false; return { name: "delete", [hook]: async () => { if (runOnce && deleted) return; const paths = await deleteAsync(targets, delOptions); if (verbose || delOptions.dryRun) { const message = delOptions.dryRun ? `Expected to be deleted: ${paths.length}` : `Deleted: ${paths.length}`; console.log(message); if (paths.length) paths.forEach((path) => { console.log(path); }); } deleted = true; } }; } export { del as default };