Skip to content

Commit

Permalink
fix: windows path broken with matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Apr 8, 2024
1 parent d88ce83 commit d127996
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/hot_hook/src/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export class Matcher {
this.#rootDirectory = rootDirectory

patterns = Array.isArray(patterns) ? patterns : [patterns]
const absolutePatterns = patterns.map((pattern) => {
if (pattern.startsWith('../')) return resolve(rootDirectory, pattern)
return pattern
})
const absolutePatterns = patterns
.map((pattern) => {
if (pattern.startsWith('../')) return resolve(rootDirectory, pattern)
return pattern
})
.map((path) => path.replace(/\\/g, '/'))

this.#matcher = picomatch(absolutePatterns || [], { dot: true })
}
Expand All @@ -21,6 +23,7 @@ export class Matcher {
* Check if a path matches the patterns
*/
match(filePath: string) {
filePath = filePath.replace(/\\/g, '/')
if (filePath.startsWith(this.#rootDirectory)) {
filePath = filePath.slice(this.#rootDirectory.length).replace(/^\//, '')
}
Expand Down

0 comments on commit d127996

Please sign in to comment.