Filesystem
API for filesystem-related functions.
Functions
Filesystem.toAbsolutePath
Converts a relative path to an absolute path.
Filesystem.toAbsolutePath(path: string, base?: string): string
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | string | Required | The path to convert. |
| base | string? | nil | The base path to use. |
Returns
| Name | Type | Description |
|---|---|---|
| absolutePath | string | The absolute path. |
Filesystem.readFile
Reads a file.
Filesystem.readFile(relativePath: string): buffer
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| relativePath | string | Required | The relative path to the file. |
Returns
| Name | Type | Description |
|---|---|---|
| contents | buffer | The contents of the file. |
Filesystem.fileExists
Checks if a file exists.
Filesystem.fileExists(path: string): boolean
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | string | Required | The path to the file relative to the script directory. |
Returns
| Name | Type | Description |
|---|---|---|
| exists | boolean | True if the file exists, false otherwise. |
Filesystem.list
Returns the files and folders present in the given directory.
Filesystem.list(path: string): DirectoryContents
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | string | Required | Path to the directory to list relative to the script directory. |
Returns
| Name | Type | Description |
|---|---|---|
| contents | DirectoryContents | No description |
Types
DirectoryContents
List of file and subfolder names in a directory
type DirectoryContents = { directories: string[], files: string[] }
Properties
| Field | Type | Description |
|---|---|---|
| directories | string[] | No description |
| files | string[] | No description |