(dir, depth)
| 1272 | } |
| 1273 | const skip = new Set(['.git', 'node_modules', 'build']); |
| 1274 | const search = (dir, depth) => { |
| 1275 | if (depth <= 0 || results.length >= 4) return; |
| 1276 | try { |
| 1277 | const entries = fs.readdirSync(dir, { withFileTypes: true }); |
| 1278 | for (const entry of entries) { |
| 1279 | if (entry.isFile() && names.includes(entry.name)) |
| 1280 | results.push(dir + '/' + entry.name); |
| 1281 | } |
| 1282 | for (const entry of entries) { |
| 1283 | if (entry.isDirectory() && !entry.name.startsWith('.') && !skip.has(entry.name)) |
| 1284 | search(dir + '/' + entry.name, depth - 1); |
| 1285 | } |
| 1286 | } catch (e) {} |
| 1287 | }; |
| 1288 | search(baseDir, maxDepth); |
| 1289 | return results; |
| 1290 | } |
no test coverage detected