removeSync

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

function · experimental · requires --allow-write

function removeSync(path: string | URL, options?: RemoveOptions): void

Synchronously 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 { existsSync } from "@ende/fs/exists";
import { removeSync } from "@ende/fs/unstable-remove";
import { makeTempDirSync } from "@ende/fs/unstable-make-temp-dir";

const tempDir = makeTempDirSync();
removeSync(tempDir);
assertFalse(existsSync(tempDir));

Source