@@ -79,21 +79,39 @@ export default class EntryFilter {
7979 }
8080
8181 #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+ }
8391
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 ;
8695 }
8796
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+ }
89104
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 ) ;
94108 }
95109
96110 #isMatchToPatterns( filepath : string , patternsRe : PatternRe [ ] , isDirectory : boolean ) : boolean {
111+ if ( patternsRe . length === 0 ) {
112+ return false ;
113+ }
114+
97115 // Trying to match files and directories by patterns.
98116 const isMatched = utils . pattern . matchAny ( filepath , patternsRe ) ;
99117
0 commit comments