MCPcopy Index your code
hub / github.com/mixedbread-ai/mgrep / getAllFilesRecursive

Method getAllFilesRecursive

src/lib/file.ts:79–103  ·  view source on GitHub ↗

* Gets all files recursively from a directory

(dir: string, root: string)

Source from the content-addressed store, hash-verified

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

Callers 1

getFilesMethod · 0.95

Calls 2

isHiddenFileMethod · 0.95
isIgnoredMethod · 0.95

Tested by

no test coverage detected