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<"ensure-directory"> if (
E
.
isRight
(
result
)) {
// directory create with success }

Syntax ​

typescript
function ensureDirectory(
  path: string
): Promise<FileSystemLeft<"ensure-directory"> | E.Ok>

Parameters ​

  • path : path of the directory to ensure.

Return value ​

  • E.Ok : if the directory exists or was created.
  • FileSystemLeft<"ensure-directory"> : if the operation fails.

See also ​

Released under the MIT license.