Syntax
readfile(path: string): stringAliases
readfileasyncArguments
| Name | Type | Description |
|---|---|---|
path | string | Workspace-relative path to the file or folder. |
Returns
| Name | Type | Description |
|---|---|---|
content | string | Full file contents. |
Description
Reads the full contents of a file from the executor workspace.
Call it with 1 parameter(s): path. The argument table explains which values are required and which ones only refine the behavior.
It returns content (string). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Read a workspace file after checking that it exists.
local path = "workspace/examples/config.json"
if isfile(path) then
local content = readfile(path)
print(content)
end