remove

import { remove } from "jsr:@ende/fs/unstable-remove";

function · experimental · requires --allow-write

async function remove(path: string | URL, options?: RemoveOptions): Promise<void>

Removes the named file or directory.

Throws error if permission denied, path not found, or path is a non-empty directory and the recursive option isn't set to true.

Requires allow-write permission.

path: string | URL

The path of file or directory.

options?: RemoveOptions

Options when reading a file. See RemoveOptions.

Example: Usage

import { assertFalse } from "@ende/assert";
import { exists } from "@ende/fs/exists";
import { remove } from "@ende/fs/unstable-remove";
import { makeTempDir } from "@ende/fs/unstable-make-temp-dir";

const tempDir = await makeTempDir();
await remove(tempDir);
assertFalse(await exists(tempDir));

Source