@@ -37,47 +37,38 @@ export async function resolve_glob_patterns(
3737 const current_actual_pattern = is_exclude
3838 ? pattern_string . substring ( 1 )
3939 : pattern_string
40+ const normalized_pattern = path . normalize ( current_actual_pattern )
4041
4142 const files_this_rule_applies_to = new Set < string > ( )
4243
43- let direct_match_found_for_current_pattern = false
44- if ( all_files_in_cache . has ( current_actual_pattern ) ) {
45- files_this_rule_applies_to . add ( current_actual_pattern )
46- direct_match_found_for_current_pattern = true
47- }
48-
49- if ( ! direct_match_found_for_current_pattern ) {
44+ if ( fs . existsSync ( normalized_pattern ) ) {
45+ if ( fs . lstatSync ( normalized_pattern ) . isDirectory ( ) ) {
46+ const dir_path = normalized_pattern
47+ for ( const cached_file of all_files_in_cache ) {
48+ const normalized_cached_file = path . normalize ( cached_file )
49+ if ( normalized_cached_file . startsWith ( dir_path + path . sep ) ) {
50+ files_this_rule_applies_to . add ( cached_file )
51+ }
52+ }
53+ } else if ( fs . lstatSync ( normalized_pattern ) . isFile ( ) ) {
54+ if ( all_files_in_cache . has ( normalized_pattern ) ) {
55+ files_this_rule_applies_to . add ( normalized_pattern )
56+ }
57+ }
58+ } else {
5059 try {
51- const glob_matches = glob . sync ( current_actual_pattern , {
52- cwd : process . cwd ( ) ,
53- absolute : true ,
54- matchBase : true
55- } )
60+ const glob_matches = glob . sync ( normalized_pattern , { absolute : true } )
5661 glob_matches . forEach ( ( match ) => {
57- if ( all_files_in_cache . has ( match ) ) {
58- files_this_rule_applies_to . add ( match )
59- } else {
60- const normalized_match = path . normalize ( match )
61- const directory_path_prefix = normalized_match . endsWith ( path . sep )
62- ? normalized_match
63- : normalized_match + path . sep
64-
65- for ( const cached_file of all_files_in_cache ) {
66- const normalized_cached_file = path . normalize ( cached_file )
67- if ( normalized_cached_file . startsWith ( directory_path_prefix ) ) {
68- files_this_rule_applies_to . add ( cached_file )
69- }
70- }
62+ const normalized_match = path . normalize ( match )
63+ if ( all_files_in_cache . has ( normalized_match ) ) {
64+ files_this_rule_applies_to . add ( normalized_match )
7165 }
7266 } )
7367 } catch ( error ) {
7468 console . warn (
75- `Failed to resolve glob pattern "${ current_actual_pattern } " (during sequential processing) :` ,
69+ `Failed to resolve glob pattern "${ normalized_pattern } " :` ,
7670 error
7771 )
78- if ( all_files_in_cache . has ( current_actual_pattern ) ) {
79- files_this_rule_applies_to . add ( current_actual_pattern )
80- }
8172 }
8273 }
8374
0 commit comments