API Reference
Classes
Fs
The fs class is used for interacting with the file system.
All file paths must be POSIX file paths (/ instead of ), and will be normalized to the target platform if running on Windows.
Initializers
bring fs;
new fs.Util();
Name | Type | Description |
---|
Static Functions
Name | Description |
---|---|
| The right-most parameter is considered {to}. Other parameters are considered an array of {from}. |
| Appends new data to the end of an existing file. |
| Retrieve the final segment of a given file path. |
| Retrieve the name of the directory from a given file path. |
| Check if the path exists. |
| Extracts the extension (without the leading dot) from the path, if possible. |
| Match files using the patterns the shell uses. |
| Checks if the given path is a directory and exists. |
| Join all arguments together and normalize the resulting path. |
| Calculate an MD5 content hash of all the files that match a glob pattern. |
| Gets the stats of the given path. |
| Create a directory. |
| Create a temporary directory. |
| Read the contents of the file as bytes. |
| Read the contents of the directory. |
| Read the entire contents of a file. |
| Read the contents of the file and convert it to JSON. |
| Convert all YAML objects from a single file into JSON objects. |
| Solve the relative path from {from} to {to} based on the current working directory. |
| Remove files and directories (modeled on the standard POSIX rm utility). |
| Set the permissions of the file, directory, etc. |
| Creates a symbolic link. |
| Gets the stats of the given path without following symbolic links. |
| If the file exists, read the contents of the file as bytes; |
| If the path exists, read the contents of the directory; |
| If the file exists and can be read successfully, read the entire contents; |
| Retrieve the contents of the file and convert it to JSON if the file exists and can be parsed successfully, otherwise, return undefined . |
| Convert all YAML objects from a single file into JSON objects if the file exists and can be parsed successfully, undefined otherwise. |
| Write bytes to a file, replacing the file if it already exists. |
| Writes data to a file, replacing the file if it already exists. |
| Writes JSON to a file, replacing the file if it already exists. |
| Writes multiple YAML objects to a file, replacing the file if it already exists. |
absolute
bring fs;
fs.absolute(...paths: Array<str>);
The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
Starting from leftmost {from} parameter, resolves {to} to an absolute path.
If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
paths
Required
- Type: str
A sequence of paths or path segments.
appendFile
bring fs;
fs.appendFile(filepath: str, data: str, options?: WriteFileOptions);
Appends new data to the end of an existing file.
filepath
Required
- Type: str
The file path that needs to be appended.