@@ -79,21 +79,39 @@ export default class EntryFilter {
79
79
}
80
80
81
81
#isMatchToPatternsSet( filepath : string , patterns : PatternsRegexSet , isDirectory : boolean ) : boolean {
82
- let fullpath = filepath ;
82
+ const isMatched = this . #isMatchToPatterns( filepath , patterns . positive . all , isDirectory ) ;
83
+ if ( ! isMatched ) {
84
+ return false ;
85
+ }
86
+
87
+ const isMatchedByRelativeNegative = this . #isMatchToPatterns( filepath , patterns . negative . relative , isDirectory ) ;
88
+ if ( isMatchedByRelativeNegative ) {
89
+ return false ;
90
+ }
83
91
84
- if ( patterns . negative . absolute . length > 0 ) {
85
- fullpath = utils . path . makeAbsolute ( this . #settings. cwd , filepath ) ;
92
+ const isMatchedByAbsoluteNegative = this . #isMatchToAbsoluteNegative( filepath , patterns . negative . absolute , isDirectory ) ;
93
+ if ( isMatchedByAbsoluteNegative ) {
94
+ return false ;
86
95
}
87
96
88
- const isMatched = this . #isMatchToPatterns( filepath , patterns . positive . all , isDirectory ) ;
97
+ return true ;
98
+ }
99
+
100
+ #isMatchToAbsoluteNegative( filepath : string , patternsRe : PatternRe [ ] , isDirectory : boolean ) : boolean {
101
+ if ( patternsRe . length === 0 ) {
102
+ return false ;
103
+ }
89
104
90
- return isMatched && ! (
91
- this . #isMatchToPatterns( filepath , patterns . negative . relative , isDirectory ) ||
92
- this . #isMatchToPatterns( fullpath , patterns . negative . absolute , isDirectory )
93
- ) ;
105
+ const fullpath = utils . path . makeAbsolute ( this . #settings. cwd , filepath ) ;
106
+
107
+ return this . #isMatchToPatterns( fullpath , patternsRe , isDirectory ) ;
94
108
}
95
109
96
110
#isMatchToPatterns( filepath : string , patternsRe : PatternRe [ ] , isDirectory : boolean ) : boolean {
111
+ if ( patternsRe . length === 0 ) {
112
+ return false ;
113
+ }
114
+
97
115
// Trying to match files and directories by patterns.
98
116
const isMatched = utils . pattern . matchAny ( filepath , patternsRe ) ;
99
117
0 commit comments