Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > FileSystem > appendToFile

FileSystem.appendToFile() method

Writes a text string to a file on disk, appending to the file if it already exists. Behind the scenes it uses fs.appendFileSync().

Signature:

static appendToFile(filePath: string, contents: string | Buffer, options?: IFileSystemWriteFileOptions): void;

Parameters

ParameterTypeDescription
filePathstringThe absolute or relative path of the file.
contentsstring | BufferThe text that should be written to the file.
optionsIFileSystemWriteFileOptions(Optional) Optional settings that can change the behavior. Type: IWriteFileOptions

Returns:

void

Remarks

Throws an error if the folder doesn't exist, unless ensureFolder=true.