Skip to content

Commit aca84d2

Browse files
Kanade-Lu卢海宇antfu
authored
fix: matchGlobs function to correctly handle negation patterns (#777)
Co-authored-by: 卢海宇 <haiyu.lu@lixinchuxing.com> Co-authored-by: Anthony Fu <github@antfu.me>
1 parent b631b47 commit aca84d2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ export function isEmpty(value: any) {
5858

5959
export function matchGlobs(filepath: string, globs: string[]) {
6060
for (const glob of globs) {
61-
if (minimatch(slash(filepath), glob))
62-
return true
61+
const isNegated = glob.startsWith('!')
62+
const match = minimatch(slash(filepath), isNegated ? glob.slice(1) : glob)
63+
if (match)
64+
return !isNegated
6365
}
6466
return false
6567
}

0 commit comments

Comments
 (0)