Function ensureDirSync

  • Synchronously 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.

    Parameters

    • dir: string | URL

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

    Returns void

    A void value that returns once the directory exists.

    https://docs.deno.com/runtime/manual/basics/permissions#file-system-access for more information on Deno's permissions system.

    import { ensureDirSync } from "@std/fs/ensure-dir";

    ensureDirSync("./bar");