Read/Write
Helper functions for reading and writing to text files.
Functions
appendFile()
function appendFile(filePath, data): void
Helper function to synchronously append data to a file.
This will throw an error if the file cannot be appended to.
Parameters
Parameter | Type |
---|---|
filePath | string |
data | string |
Returns
void
Defined in
packages/complete-node/src/functions/readWrite.ts:15
deleteLineInFile()
function deleteLineInFile(filePath, lineNumber): void
Helper function to delete a specific line in a text file.
This assumes that the file is a text file and uses an encoding of "utf8".
This will print an error message and exit the program if the file cannot be read.
Parameters
Parameter | Type |
---|---|
filePath | string |
lineNumber | number |
Returns
void
Defined in
packages/complete-node/src/functions/readWrite.ts:30
prependFile()
function prependFile(filePath, data): void
Helper function to synchronously prepend data to a file.
This will throw an error if the file cannot be prepended to.
Parameters
Parameter | Type |
---|---|
filePath | string |
data | string |
Returns
void
Defined in
packages/complete-node/src/functions/readWrite.ts:51
readFile()
function readFile(filePath): string
Helper function to synchronously read a file.
This assumes that the file is a text file and uses an encoding of "utf8".
This will throw an error if the file cannot be read.
Parameters
Parameter | Type |
---|---|
filePath | string |
Returns
string
Defined in
packages/complete-node/src/functions/readWrite.ts:64
readFileAsync()
function readFileAsync(filePath): Promise<string>
Helper function to asynchronously read a file.
This assumes that the file is a text file and uses an encoding of "utf8".
This will throw an error if the file cannot be read.
Parameters
Parameter | Type |
---|---|
filePath | string |
Returns
Promise
<string
>
Defined in
packages/complete-node/src/functions/readWrite.ts:83
replaceLineInFile()
function replaceLineInFile(
filePath,
lineNumber,
newLine): void
Helper function to replace a specific line in a text file.
This assumes that the file is a text file and uses an encoding of "utf8".
This will print an error message and exit the program if the file cannot be read.
Parameters
Parameter | Type |
---|---|
filePath | string |
lineNumber | number |
newLine | string |
Returns
void
Defined in
packages/complete-node/src/functions/readWrite.ts:102
replaceTextInFile()
function replaceTextInFile(
filePath,
searchValue,
replaceValue): void
Helper function to synchronously replace text in a file.
This assumes that the file is a text file and uses an encoding of "utf8".
This will print an error message and exit the program if the file cannot be read.
Parameters
Parameter | Type |
---|---|
filePath | string |
searchValue | string | RegExp |
replaceValue | string |
Returns
void
Defined in
packages/complete-node/src/functions/readWrite.ts:129
writeFile()
function writeFile(filePath, data): void
Helper function to synchronously write data to a file.
This will throw an error if the file cannot be written to.
Parameters
Parameter | Type |
---|---|
filePath | string |
data | string |
Returns
void
Defined in
packages/complete-node/src/functions/readWrite.ts:144
writeFileAsync()
function writeFileAsync(filePath, data): Promise<void>
Helper function to asynchronously write data to a file.
This will throw an error if the file cannot be written to.
Parameters
Parameter | Type |
---|---|
filePath | string |
data | string |
Returns
Promise
<void
>