UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

39 lines (32 loc) 1.34 kB
import { createRequire as __cjs_createRequire } from "node:module"; const __cjs_require = __cjs_createRequire(import.meta.url); const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process; const __cjs_getBuiltinModule = (module) => { // Check if we're in Node.js and version supports getBuiltinModule if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) { const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number); // Node.js 20.16.0+ and 22.3.0+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) { return __cjs_getProcess.getBuiltinModule(module); } } // Fallback to createRequire return __cjs_require(module); }; const { unlink, rm } = __cjs_getBuiltinModule("node:fs/promises"); import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js'; const remove = async (path, options = {}) => { assertValidFileOrDirectoryPath(path); try { await unlink(path); } catch { } try { await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay }); } catch { } }; export { remove as default };