MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / scanCodeFiles

Function scanCodeFiles

scripts/useless-key-scanner.mjs:73–91  ·  view source on GitHub ↗

* @param {string} codeDir * @param {Array } scannedFiles * @param {Array } excludeFiles * @returns {Promise >}

(codeDir = "", scannedFiles = [], excludeFiles = [])

Source from the content-addressed store, hash-verified

71 * @returns {Promise<Array<string>>}
72 */
73async function scanCodeFiles(codeDir = "", scannedFiles = [], excludeFiles = []) {
74 const codeFiles = fs.readdirSync(codeDir);
75 for (const codeFile of codeFiles) {
76 const codeFilePath = path.join(codeDir, codeFile);
77 if (excludeFiles.some((excludeFile) => codeFilePath.includes(excludeFile))) continue;
78 try {
79 if (fs.statSync(codeFilePath).isDirectory()) {
80 await scanCodeFiles(codeFilePath, scannedFiles, excludeFiles);
81 } else {
82 if (INCLUDE_EXT_NAMES.includes(path.extname(codeFilePath))) {
83 scannedFiles.push(codeFilePath);
84 }
85 }
86 } catch (error) {
87 // ignore
88 }
89 }
90 return scannedFiles;
91}
92
93/**
94 * @param {Map<string, boolean>} langKeys

Callers 1

mainThreadFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected