MCPcopy Create free account
hub / github.com/cloudflare/agents / writeFile

Function writeFile

packages/shell/src/git/fs-adapter.ts:104–119  ·  view source on GitHub ↗
(path: string, data: string | Uint8Array)

Source from the content-addressed store, hash-verified

102 },
103
104 async writeFile(path: string, data: string | Uint8Array): Promise<void> {
105 // Ensure parent directory exists
106 const parent = path.replace(/\/[^/]+$/, "");
107 if (parent && parent !== "/" && parent !== path) {
108 try {
109 await fs.mkdir(parent, { recursive: true });
110 } catch {
111 // already exists
112 }
113 }
114 if (typeof data === "string") {
115 await fs.writeFile(path, data);
116 } else {
117 await fs.writeFileBytes(path, data);
118 }
119 },
120
121 async unlink(path: string): Promise<void> {
122 try {

Callers 3

applyTextEditsFunction · 0.50
rollbackSnapshotsFunction · 0.50

Calls 4

replaceMethod · 0.65
mkdirMethod · 0.65
writeFileMethod · 0.65
writeFileBytesMethod · 0.65

Tested by

no test coverage detected