Skip to content

Commit

Permalink
fix: matchGlobs function to correctly handle negation patterns (#777)
Browse files Browse the repository at this point in the history
Co-authored-by: 卢海宇 <haiyu.lu@lixinchuxing.com>
Co-authored-by: Anthony Fu <github@antfu.me>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent b631b47 commit aca84d2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ export function isEmpty(value: any) {

export function matchGlobs(filepath: string, globs: string[]) {
for (const glob of globs) {
if (minimatch(slash(filepath), glob))
return true
const isNegated = glob.startsWith('!')
const match = minimatch(slash(filepath), isNegated ? glob.slice(1) : glob)
if (match)
return !isNegated
}
return false
}
Expand Down

0 comments on commit aca84d2

Please sign in to comment.