diff options
| author | Anas H. Sulaiman <[email protected]> | 2025-06-13 14:57:03 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-13 14:57:03 -0400 |
| commit | 1cefe21d2a4829170a9cb91274bdfd414c952e7b (patch) | |
| tree | 5bba44a4c6630b7ca8cfd1605cdbfc12fd5eebc4 /packages/core/src/utils/bfsFileSearch.ts | |
| parent | 084b58a50edeaccc2261983fce2988e210637a0f (diff) | |
reuse filtering service in `bfsFileSearch` (#1018)
Diffstat (limited to 'packages/core/src/utils/bfsFileSearch.ts')
| -rw-r--r-- | packages/core/src/utils/bfsFileSearch.ts | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/packages/core/src/utils/bfsFileSearch.ts b/packages/core/src/utils/bfsFileSearch.ts index 6b05526f..7cd33c03 100644 --- a/packages/core/src/utils/bfsFileSearch.ts +++ b/packages/core/src/utils/bfsFileSearch.ts @@ -4,11 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { GitIgnoreParser, GitIgnoreFilter } from './gitIgnoreParser.js'; -import { isGitRepository } from './gitUtils.js'; import * as fs from 'fs/promises'; import * as path from 'path'; import { Dirent } from 'fs'; +import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; // Simple console logger for now. // TODO: Integrate with a more robust server-side logger. @@ -22,8 +21,7 @@ interface BfsFileSearchOptions { ignoreDirs?: string[]; maxDirs?: number; debug?: boolean; - respectGitIgnore?: boolean; - projectRoot?: string; + fileService?: FileDiscoveryService; } /** @@ -42,21 +40,13 @@ export async function bfsFileSearch( ignoreDirs = [], maxDirs = Infinity, debug = false, - respectGitIgnore = true, - projectRoot = rootDir, + fileService, } = options; const foundFiles: string[] = []; const queue: string[] = [rootDir]; const visited = new Set<string>(); let scannedDirCount = 0; - let gitIgnoreFilter: GitIgnoreFilter | null = null; - if (respectGitIgnore && isGitRepository(projectRoot)) { - const parser = new GitIgnoreParser(projectRoot); - await parser.initialize(); - gitIgnoreFilter = parser; - } - while (queue.length > 0 && scannedDirCount < maxDirs) { const currentDir = queue.shift()!; if (visited.has(currentDir)) { @@ -79,7 +69,7 @@ export async function bfsFileSearch( for (const entry of entries) { const fullPath = path.join(currentDir, entry.name); - if (gitIgnoreFilter?.isIgnored(fullPath)) { + if (fileService?.shouldIgnoreFile(fullPath)) { continue; } |
