@@ -6,6 +6,12 @@ import {
66 DEFAULT_EXCLUDE_PATTERNS ,
77} from '../core/patterns.js' ;
88
9+ interface FindFilesOptions {
10+ include ?: string [ ] ;
11+ exclude ?: string [ ] ;
12+ files ?: string [ ] ;
13+ }
14+
915/**
1016 * Recursively finds all files in the given directory matching the include patterns,
1117 * while excluding files and directories that match the exclude patterns.
@@ -15,7 +21,7 @@ import {
1521 */
1622export async function findFiles (
1723 rootDir : string ,
18- opts : { include : string [ ] ; exclude : string [ ] ; files ?: string [ ] } ,
24+ opts : FindFilesOptions ,
1925) : Promise < string [ ] > {
2026 // If --files provided, keep existing replacement behavior
2127 if ( opts . files && opts . files . length > 0 ) {
@@ -24,7 +30,7 @@ export async function findFiles(
2430
2531 const defaultPatterns = getDefaultPatterns ( ) ;
2632 const rawInclude =
27- opts . include . length > 0
33+ opts . include && opts . include . length > 0
2834 ? [ ...defaultPatterns , ...opts . include ]
2935 : defaultPatterns ;
3036 const includePatterns = rawInclude . flatMap ( expandBraceSets ) ;
@@ -69,7 +75,7 @@ export async function findFiles(
6975 if (
7076 shouldExclude ( entry . name , relativeToRoot , [
7177 ...DEFAULT_EXCLUDE_PATTERNS ,
72- ...opts . exclude ,
78+ ...( opts . exclude ?? [ ] ) ,
7379 ] )
7480 ) {
7581 continue ;
0 commit comments