@visulima/fs
Version:
Human friendly file system utilities for Node.js
24 lines (23 loc) • 820 B
TypeScript
import type { RetryOptions } from "../types.d.ts";
/**
* Ensures that a directory is empty.
* Deletes directory contents if the directory is not empty.
* If the directory does not exist, it is created.
* The directory itself is not deleted.
* @param dir The path to the directory to empty.
* @param options Optional configuration for the operation. See {@link RetryOptions}.
* @example
* ```javascript
* import { emptyDirSync } from "@visulima/fs";
* import { join } from "node:path";
*
* try {
* emptyDirSync(join("/tmp", "my-app-temp"));
* console.log("Temporary directory emptied or created.");
* } catch (error) {
* console.error("Failed to empty directory:", error);
* }
* ```
*/
declare const emptyDirSync: (dir: URL | string, options?: RetryOptions) => void;
export default emptyDirSync;