configuration options for the writeTextFile and writeFile function.

interface WriteFileConfig {
    append: boolean;
    create: boolean;
    mode: undefined | number;
    signal?: AbortSignal;
}

Properties

append: boolean

when set to true, the new text will be appended to the file, instead of overwriting the previous contents.

false

create: boolean

allow the creation of a new file if one does not already exist at the specified path. when set to false, and a file does not already exist at the specified path, then an error will be thrown, causing the write operation promise to be rejected.

true

mode: undefined | number

supply an optional unix r/w/x-permission mode to apply to the file.

Note

setting file chmod-permissions on windows does nothing! (is that a limitation of deno? I don't know)

  • if you're unfamiliar with this, check out this stack-exchange answer: link.
  • if you'd like to calculate the permission number, try this online permission calculator: link.
  • REMEMBER: the file permission number is in octal-representation! so for setting an "allow all" permission, which is denoted as "777", you would pass 0o777.

0o644 (this is an assumption, since that's the linux default) (but node's docs mentions the default to be 0o666)

signal?: AbortSignal

provide an optional abort signal to allow the cancellation of the file write operation.

if the signal becomes aborted, the write file operation will be stopped and the promise returned will be rejected with an AbortError.

undefined