UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

22 lines (18 loc) 762 B
'use strict'; const node_fs = require('node:fs'); const path = require('@visulima/path'); const utils = require('@visulima/path/utils'); const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const emptyDir = /* @__PURE__ */ __name((dir, options) => { assertValidFileOrDirectoryPath(dir); if (!node_fs.existsSync(dir)) { node_fs.mkdirSync(dir, { recursive: true }); return; } for (const item of node_fs.readdirSync(dir)) { node_fs.rmSync(path.join(utils.toPath(dir), item), { ...options, force: true, recursive: true }); } }, "emptyDir"); module.exports = emptyDir;