nsuite - v1.0.1
    Preparing search index...

    Function writeFileSafely

    • Safely writes content to a file, creating parent directories if they don't exist.

      Parameters

      • filePath: string

        The path to the file to be written.

      • content:
            | string
            | Buffer<ArrayBufferLike>
            | DataView<ArrayBufferLike>
            | Uint8Array<ArrayBufferLike>

        The content to write to the file.

      • Optionaloptions: WriteFileOptions

        Optional settings for the write operation.

      Returns Promise<void>

      • A promise that resolves when the file has been written.
      import { writeFileSafely } from "nsuite";
      await writeFileSafely("./logs/error.log", "Error message", { encoding: "utf8" });