MCPcopy Create free account
hub / github.com/Tencent/libpag / replaceInFile

Function replaceInFile

web/script/restore.replace.js:43–50  ·  view source on GitHub ↗
(filePath, searchString, replacement)

Source from the content-addressed store, hash-verified

41}
42
43function replaceInFile(filePath, searchString, replacement) {
44 const data = fs.readFileSync(filePath, 'utf-8');
45 if (data.includes(searchString)) {
46 const updatedData = data.replace(new RegExp(searchString, 'g'), replacement);
47 fs.writeFileSync(filePath, updatedData, 'utf-8');
48 console.log(`In file ${filePath}, "${searchString}" was replaced with "${replacement}"`);
49 }
50}
51
52function replaceFileNameInFiles() {
53 const dir = path.resolve(__dirname, "../lib-mt/");

Callers 2

replaceFileNameInFilesFunction · 0.85
replacePathInFilesFunction · 0.85

Calls 1

logMethod · 0.65

Tested by

no test coverage detected