ensureFileSync

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

function

function ensureFileSync(filePath: string | URL): void

Synchronously ensures that the file exists.

If the file already exists, this function does nothing. If the parent directories for the file do not exist, they are created.

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

filePath: string | URL

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

Returns

A void value that returns once the file exists.

Example: Usage

import { ensureFileSync } from "@ende/fs/ensure-file";

ensureFileSync("./folder/targetFile.dat");

See also

Source