File Collection
Source: src/core/file-collector.ts
What
Globs the project directory for TypeScript files matching include/exclude patterns from the config.
Why
Only user source files should be analyzed. Test files, generated code, declaration files, and dependencies are excluded to avoid false positives and keep scans fast.
Input
targetPath: string // directory to glob
config: NestjsDoctorConfig // include/exclude patterns
Output
string[] // sorted array of absolute file paths
For monorepos:
Map<string, string[]> // project name → sorted file paths
How It Works
Uses tinyglobby to match files:
- Reads
config.includepatterns (default:["**/*.ts"]) - Reads
config.excludepatterns (default + user additions) - Runs the glob from
targetPath - Returns results sorted alphabetically for deterministic output
For monorepos, collectMonorepoFiles calls collectFiles once per sub-project using each project's root path. All sub-project globs run in parallel via Promise.all.
Debugging Tips
- If files are missing from the scan, check:
- Does the file match an
includepattern? - Does the file match an
excludepattern? (remember, defaults exclude test files, mocks, seeders)
- Does the file match an
- Run with
--verboseto see which files were scanned (the file count is shown in the report). - The glob is relative to the target path. Absolute patterns are not supported.