* Gets all files recursively from a directory
(dir: string, root: string)
| 77 | * Gets all files recursively from a directory |
| 78 | */ |
| 79 | private *getAllFilesRecursive(dir: string, root: string): Generator<string> { |
| 80 | try { |
| 81 | const entries = fs.readdirSync(dir, { withFileTypes: true }); |
| 82 | for (const entry of entries) { |
| 83 | const fullPath = path.join(dir, entry.name); |
| 84 | |
| 85 | if (this.isHiddenFile(fullPath, root)) { |
| 86 | continue; |
| 87 | } |
| 88 | |
| 89 | if (this.isIgnored(fullPath, root)) { |
| 90 | continue; |
| 91 | } |
| 92 | |
| 93 | if (entry.isDirectory()) { |
| 94 | yield* this.getAllFilesRecursive(fullPath, root); |
| 95 | } else if (entry.isFile()) { |
| 96 | yield fullPath; |
| 97 | } |
| 98 | } |
| 99 | } catch (error) { |
| 100 | // Log permission or other filesystem errors |
| 101 | console.error(`Warning: Failed to read directory ${dir}:`, error); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | *getFiles(dirRoot: string): Generator<string> { |
| 106 | // Preload root .mgrepignore to ensure it's cached |
no test coverage detected