ensureDir

import { ensureDir } from "jsr:@ende/fs";

function

async function ensureDir(dir: string | URL): Promise<void>

Asynchronously ensures that the directory exists, like mkdir -p.

If the directory already exists, this function does nothing. If the directory does not exist, it is created.

Requires --allow-read and --allow-write permissions.

dir: string | URL

The path of the directory to ensure, as a string or URL.

Returns

A promise that resolves once the directory exists.

Example: Usage

import { ensureDir } from "@ende/fs/ensure-dir";

await ensureDir("./bar");

See also

Source