File collection

Source: src/engine/file-collector.ts

Globs the project directory for TypeScript files matching the include and exclude patterns from the config. Only user source files should be analyzed, so test files, generated code, declaration files, and dependencies are left out. That avoids false positives and keeps scans fast.

Input is the directory to glob and the resolved config:

targetPath: string              // directory to glob
config: NestjsDoctorConfig      // include/exclude patterns

The result is a sorted list of absolute paths:

string[]    // sorted array of absolute file paths

For monorepos, the result is keyed by sub-project:

Map<string, string[]>    // project name → sorted file paths

How it works

Uses tinyglobby to match files:

  1. Reads config.include patterns (default: ["**/*.ts"])
  2. Reads config.exclude patterns (defaults plus user additions)
  3. Runs the glob from targetPath
  4. 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 that the file matches an include pattern and does not match an exclude pattern. The defaults exclude test files, mocks, and seeders.
  • Run with --verbose to 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.