UNPKG

@thi.ng/file-io

Version:

Assorted file I/O utils (with logging support) for NodeJS/Bun

16 lines (15 loc) 453 B
import { rmSync, unlinkSync } from "node:fs"; const deleteFile = (path, logger, dryRun = false) => { logger?.info(`${dryRun ? "[dryrun] " : ""}deleting file: ${path}`); if (dryRun) return; unlinkSync(path); }; const deleteDir = (path, logger, dryRun = false) => { logger?.info(`${dryRun ? "[dryrun] " : ""}deleting file: ${path}`); if (dryRun) return; rmSync(path, { recursive: true, force: true }); }; export { deleteDir, deleteFile };