MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / replaceInFile

Function replaceInFile

src/sidebarApps/searchInFiles/worker.js:149–156  ·  view source on GitHub ↗

* Replace a string in the content of a file. * @param {object} arg - The content of the file to search. * @param {import('lib/fileList').Tree} arg.file - The content of the file to search. * @param {string} content - The content of the file to search. * @param {RegExp} arg.search - The string to

({ file, content, search, replace })

Source from the content-addressed store, hash-verified

147 * @param {string} arg.replace - The string to replace with.
148 */
149function replaceInFile({ file, content, search, replace }) {
150 const text = content.replace(search, replace);
151
152 self.postMessage({
153 action: "replace-result",
154 data: { file, text },
155 });
156}
157
158/**
159 * Gets surrounding text of a match.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected