Skip to content

ensureDirectory

Ensures a directory exists.

Example

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
} from "@duplojs/utils";
const
result
= await
SF
.
ensureDirectory
("/tmp/project");
// result: E.Ok | SF.FileSystemLeft if (
E
.
isRight
(
result
)) {
// directory create with success }

Syntax

typescript
function ensureDirectory(
  path: string | URL
): Promise<FileSystemLeft | E.Ok>

Parameters

  • path : path of the directory to ensure.

Return value

  • E.Ok : if the directory exists or was created.
  • FileSystemLeft : if the operation fails.

See also

Released under the MIT license.