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

Function getFilesInDir

web/script/restore.replace.js:24–41  ·  view source on GitHub ↗
(dir, extension)

Source from the content-addressed store, hash-verified

22}
23
24function getFilesInDir(dir, extension) {
25 let filesList = [];
26
27 const files = fs.readdirSync(dir);
28 files.forEach(file => {
29 const fullPath = path.join(dir, file);
30 const stat = fs.statSync(fullPath);
31
32 if (stat.isFile() && fullPath.endsWith(extension)) {
33 filesList.push(fullPath);
34 }
35 else if (stat.isDirectory()) {
36 filesList = filesList.concat(getFilesInDir(fullPath, extension));
37 }
38 });
39
40 return filesList;
41}
42
43function replaceInFile(filePath, searchString, replacement) {
44 const data = fs.readFileSync(filePath, 'utf-8');

Callers 2

replaceFileNameInFilesFunction · 0.85
replacePathInFilesFunction · 0.85

Calls 2

joinMethod · 0.80
concatMethod · 0.45

Tested by

no test coverage detected