text
The text
utility makes it easier to read and write to any file within in your checks.
This utility expects an absolute path to a JSON file and returns an object with methods that help you read and write to any file.
exists
Returns a boolean value indicating whether or not the file exists on disk.
Example
get
Returns
Returns the contents of a file as an array of strings representing each line. If the file does not exist, undefined
will be returned.
Example
contains
Parameters
An array of strings, representing lines of text.
Returns
Returns a boolean value indicating whether specified lines exist in the file. If the file does not exist, false
will be returned.
Example
set
Overwrites the entire contents of a file with the provided lines of text. If the file does not exist, it will be created.
Parameters
An array of strings, representing lines of text.
Example
remove
Removes lines of text from a file, if they exist. Lines of text that are not included in the array will not be affected.
Parameters
An array of strings, representing lines of text.
Example
delete
Deletes a file from disk.