Function emptyDir

  • Asynchronously ensures that a directory is empty.

    If the directory does not exist, it is created. The directory itself is not deleted.

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

    Parameters

    • dir: string | URL

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

    Returns Promise<void>

    A void promise that resolves once the directory is empty.

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

    import { emptyDir } from "@std/fs/empty-dir";

    await emptyDir("./foo");