Skip to content

Commit

Permalink
fix: avoid path.relative on already-relative paths
Browse files Browse the repository at this point in the history
While it‘s perfectly fine on Unix, it‘s apparently broken on Windows.

Closes #162
  • Loading branch information
aleclarson committed Nov 9, 2024
1 parent 92a7741 commit 0fe07cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ export default (opts: PluginOptions = {}): Plugin => {
}

const isIncludedRelative = getIncluder(
config.include?.map((p) => relative(configDir, p)),
config.exclude?.map((p) => relative(configDir, p)),
config.include?.map((p) => ensureRelative(configDir, p)),
config.exclude?.map((p) => ensureRelative(configDir, p)),
outDir
)

Expand Down Expand Up @@ -409,3 +409,7 @@ function compileGlob(glob: string) {
globstar: true,
}).regex
}

function ensureRelative(dir: string, path: string) {
return isAbsolute(path) ? relative(dir, path) : path
}

0 comments on commit 0fe07cd

Please sign in to comment.