Functions for local file I/O. All functions are synchronous.
- file
- readFile(fileName) ⇒
string
|buffer
⏏ - writeFile(fileName, fileContent) ⏏
- isFile(fileName) ⇒
boolean
⏏ - isFolder(folderName) ⇒
boolean
⏏ - makeFolder(folderName) ⇒
boolean
⏏ - listFolders(folderName) ⇒
array
⏏ - listFiles(folderName) ⇒
array
⏏ - deleteFolder(folderName) ⇒
boolean
⏏ - deleteFile(fileName) ⇒
boolean
⏏ - readJSON(fileName) ⇒
object
⏏ - writeJSON(fileName, fileContent) ⏏
- updateJSON(fileName, updateObject) ⏏
- checkCommand(commandString) ⇒
boolean
⏏
- readFile(fileName) ⇒
Reads a local file and returns the contents.
Kind: Exported function
Returns: string
| buffer
- - File contents, will be converted to a string if possible
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
Writes buffer or string content to a local file.
Kind: Exported function
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
fileContent | string | buffer |
Content to write |
Check if a local file exists.
Kind: Exported function
Returns: boolean
- True if the file exists
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
Check if the given path is a folder.
Kind: Exported function
Returns: boolean
- True if the give path exists and is a folder
Param | Type | Description |
---|---|---|
folderName | string |
Path to local folder |
Create a new folder at the given path.
Kind: Exported function
Returns: boolean
- True if the folder was successfully created
Param | Type | Description |
---|---|---|
folderName | string |
Path to local folder |
Return a list of folders at the given path. Does not include hidden folders.
Kind: Exported function
Returns: array
- A list of folder names
Param | Type | Description |
---|---|---|
folderName | string |
Path to local folder |
Return a list of files at the given path. Does not include hidden files.
Kind: Exported function
Returns: array
- A list of files names
Param | Type | Description |
---|---|---|
folderName | string |
Path to local folder |
Delete the folder at the given path.
Kind: Exported function
Returns: boolean
- Returns true if the folder was successfully deleted
Param | Type | Description |
---|---|---|
folderName | string |
Path to local folder |
Deletes the local file.
Kind: Exported function
Returns: boolean
- True if the file exists and was deleted.
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
Reads the local JSON file and returns its object representation.
Kind: Exported function
Returns: object
- Contents of the local file parsed as an object
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
Writes a serializable object as JSON to a local file.
Kind: Exported function
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
fileContent | object |
Content to write as JSON |
Given an object, reads a local JSON file and merges the object with file contents, writing back the merged object as JSON.
Kind: Exported function
Param | Type | Description |
---|---|---|
fileName | string |
Path to local file |
updateObject | object |
A serializable object to be merged with the JSON file |
Checks whether the command exists, i.e. can be run with an exec() statement.
Kind: Exported function
Returns: boolean
- True if the command exists
Param | Type | Description |
---|---|---|
commandString | string |
A shell comment to be tested |