ApplesauceOS
Read Markdown ↗Download .md

writeFile

Write UTF-8 text to a file.

js
writeFile(path, content)

Arguments

ArgumentTypeMeaning
pathstringFile path.
contentstringText to write.

Returns

null on success; error string on failure.

Example

js
const error = writeFile(__dirname + "/result.json", JSON.stringify({ok: true}));
if (error !== null) throw new Error(error);

Notes

Native file helpers do not resolve relative paths like require(); use __dirname or scriptsDir().

All JavaScript APIs · Automation playbook