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

Method replaceInFile

packages/shell/src/memory.ts:220–232  ·  view source on GitHub ↗
(
    path: string,
    search: string,
    replacement: string,
    options?: StateSearchOptions
  )

Source from the content-addressed store, hash-verified

218 }
219
220 async replaceInFile(
221 path: string,
222 search: string,
223 replacement: string,
224 options?: StateSearchOptions
225 ): Promise<StateReplaceResult> {
226 const current = await this.readFile(path);
227 const result = replaceTextContent(current, search, replacement, options);
228 if (result.replaced > 0) {
229 await this.writeFile(path, result.content);
230 }
231 return result;
232 }
233
234 async replaceInFiles(
235 pattern: string,

Callers

nothing calls this directly

Calls 3

readFileMethod · 0.95
writeFileMethod · 0.95
replaceTextContentFunction · 0.90

Tested by

no test coverage detected