File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,16 +64,26 @@ export function classifyExcludes(excludedPatterns: string[]) {
6464 * @return A promise that resolves to an array of file paths.
6565 */
6666export async function getFiles ( args : Args , pattern : Patterns ) : Promise < string [ ] > {
67- // 1. Create the Glob instance
67+ const { dirs, filePatterns } = classifyExcludes ( pattern . exclude ) ;
68+
6869 const g = new Glob ( pattern . include , {
6970 ignore : {
70- ignored : ( p : Path ) => ignoreFunc ( p , pattern . exclude ) ,
71+ // Prune entire directory subtrees — glob won't enter these dirs at all
72+ childrenIgnored : ( p : Path ) => dirs . some ( ( d ) => p . isNamed ( d ) ) ,
73+ // Filter individual files by name or glob pattern
74+ ignored : ( p : Path ) =>
75+ filePatterns . some ( ( fp ) => {
76+ const type = detectPatternType ( fp ) ;
77+ if ( type === "file" ) {
78+ return p . isNamed ( fp ) ;
79+ }
80+ return minimatch ( p . relative ( ) , fp ) ;
81+ } ) ,
7182 } ,
7283 nodir : true ,
7384 cwd : args . paths . cwd ,
7485 root : args . paths . root ? path . resolve ( args . paths . root ) : undefined ,
7586 } ) ;
7687
77- // 2. Return the walk() promise, which resolves to an array of all file paths
7888 return g . walk ( ) ;
7989}
You can’t perform that action at this time.
0 commit comments