(dir: string)
| 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 |
no test coverage detected