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

Method getDirectoryIgnoreFilter

src/lib/file.ts:116–137  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

114 }
115
116 private getDirectoryIgnoreFilter(dir: string): ReturnType<typeof ignore> {
117 if (this.ignoreCache.has(dir)) {
118 return this.ignoreCache.get(dir) ?? ignore();
119 }
120
121 const ig = ignore();
122
123 // Load .gitignore
124 const gitignorePath = path.join(dir, ".gitignore");
125 if (fs.existsSync(gitignorePath)) {
126 ig.add(fs.readFileSync(gitignorePath, "utf8"));
127 }
128
129 // Load .mgrepignore
130 const mgrepignorePath = path.join(dir, ".mgrepignore");
131 if (fs.existsSync(mgrepignorePath)) {
132 ig.add(fs.readFileSync(mgrepignorePath, "utf8"));
133 }
134
135 this.ignoreCache.set(dir, ig);
136 return ig;
137 }
138
139 isIgnored(filePath: string, root: string): boolean {
140 // Always ignore hidden files

Callers 3

getFilesMethod · 0.95
isIgnoredMethod · 0.95
loadMgrepignoreMethod · 0.95

Calls 1

addMethod · 0.80

Tested by

no test coverage detected