To use appendFileSync
function from fs-extra
library in TypeScript, we need to first install both fs-extra
and @types/fs-extra
packages.
67 chars3 lines
Once the packages are installed, we can import the appendFileSync
function from fs-extra
in our TypeScript file and use it as follows:
index.ts161 chars7 lines
Here, appendFileSync
function takes two arguments:
filePath
- a string representing the file path that we want to append the data to.data
- a string or a buffer containing the data that we want to append to the file.This function appends the data to the end of the specified file and returns undefined
.
Note: While using appendFileSync
, we should make sure that the file path exists, otherwise, it will throw an error.
gistlibby LogSnag