MCPcopy Index your code
hub / github.com/Sandpack/nodebox-runtime / writeFile

Method writeFile

packages/nodebox/src/modules/fs.ts:121–135  ·  view source on GitHub ↗
(path: string, content: FileContent, options?: WriteFileOptions)

Source from the content-addressed store, hash-verified

119 public async writeFile(path: string, content: FileContent, options: WriteFileOptions): Promise<void>;
120
121 public async writeFile(path: string, content: FileContent, options?: WriteFileOptions): Promise<void> {
122 let encoding = undefined;
123 let recursive = false;
124
125 if (typeof options === 'object') {
126 encoding = options.encoding;
127 recursive = !!options.recursive;
128 } else if (typeof options === 'string') {
129 encoding = options;
130 }
131
132 await this.channel.send('fs/writeFile', { path, content, encoding, recursive }).catch((error) => {
133 throw new Error(format('Failed to write file at path "%s"', path), { cause: error });
134 });
135 }
136
137 public async readdir(path: string): Promise<string[]> {
138 const response = await this.channel.send('fs/readdir', { path }).catch((error) => {

Callers 5

writeWorkerFunction · 0.80
runSandpackCDNProxyFunction · 0.80

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected