Skip to content

appendTextFile ​

Appends text content to the end of a file.

Example ​

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
} from "@duplojs/utils";
const
result
= await
SF
.
appendTextFile
("/tmp/file.txt", "I ❤️ DuploJS \n");
// result: E.Ok | SF.FileSystemLeft<"append-text-file"> if (
E
.
isRight
(
result
)) {
// "I ❤️ DuploJS" append with success }

Syntax ​

typescript
function appendTextFile(
  path: string,
  data: string
): Promise<FileSystemLeft<"append-text-file"> | E.Ok>

Parameters ​

  • path : target file path.
  • data : text content to append.

Return value ​

  • E.Ok : if the operation succeeds.
  • FileSystemLeft<"append-text-file"> : if the operation fails.

See also ​

Released under the MIT license.