Skip to content

remove ​

Removes a file or directory.

Example ​

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
} from "@duplojs/utils";
const
result
= await
SF
.
remove
("/tmp/file.txt");
// result: E.Ok | SF.FileSystemLeft<"remove"> if (
E
.
isRight
(
result
)) {
// element remove with success } await
SF
.
remove
("/tmp/project", {
recursive
: true });

Syntax ​

typescript
function remove(
  path: string,
  params?: {
    recursive?: boolean
  }
): Promise<FileSystemLeft<"remove"> | E.Ok>

Parameters ​

  • path : path to remove.
  • params.recursive : removes a non-empty directory if true.

Return value ​

  • E.Ok : if removal succeeds.
  • FileSystemLeft<"remove"> : if removal fails.

See also ​

  • copy - Copies a file or directory.

Released under the MIT license.