Filesystem

writefile

Writes content to a workspace file, replacing the file if it already exists.

Syntax

writefile(path: string, content: string)
Aliases writefileasync

Arguments

NameTypeDescription
pathstringWorkspace-relative path to the file or folder.
contentstringText or byte string to write.

Description

Writes content to a workspace file, replacing the file if it already exists.

Call it with 2 parameter(s): path, content. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Write text to a workspace-relative file.

makefolder("workspace/examples")
writefile("workspace/examples/config.json", '{"enabled":true}')