Skip to main content

writeToFile

codebolt.fs.writeToFile(relPath: string, newContent: string): Promise<WriteToFileResponse>
Writes content to a file at the specified path.

Parameters

NameTypeDescription
relPathstringThe relative path of the file to write to.
newContentstringThe new content to write into the file.

Returns:

 Promise<WriteToFileResponse>
A promise that resolves with the write operation result.

Example

// Let's assume you want to write content to a file named example.txt in the /home/user/documents directory.

codebolt.fs.writeToFile('/home/user/documents/example.txt', 'This is the new content.');