Skip to content

Commit b4d3639

Browse files
committed
fix: filter out empty paths when creating ignore
resolves #462
1 parent 2ac0fc5 commit b4d3639

File tree

1 file changed

+14
-12
lines changed
  • packages/vite-plugin-checker/src

1 file changed

+14
-12
lines changed

packages/vite-plugin-checker/src/glob.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ export function createIgnore(_root: string, pattern: string | string[] = []) {
66
const paths = Array.isArray(pattern) ? pattern : [pattern]
77
const root = _root.replace(/\\/g, '/')
88

9-
const globs = paths.flatMap((f) => {
10-
const resolvedPath = resolve(root, f)
11-
const relativePath = relative(root, resolvedPath).replace(/\\/g, '/')
12-
try {
13-
const isDirectory =
14-
!relativePath.includes('*') && statSync(resolvedPath).isDirectory()
15-
if (isDirectory) {
16-
return [relativePath, join(relativePath, '**/*').replace(/\\/g, '/')]
17-
}
18-
} catch {}
19-
return [relativePath]
20-
})
9+
const globs = paths
10+
.flatMap((f) => {
11+
const resolvedPath = resolve(root, f)
12+
const relativePath = relative(root, resolvedPath).replace(/\\/g, '/')
13+
try {
14+
const isDirectory =
15+
!relativePath.includes('*') && statSync(resolvedPath).isDirectory()
16+
if (isDirectory) {
17+
return [relativePath, join(relativePath, '**/*').replace(/\\/g, '/')]
18+
}
19+
} catch {}
20+
return [relativePath]
21+
})
22+
.filter(Boolean)
2123

2224
const matcher = picomatch(globs, { cwd: root })
2325

0 commit comments

Comments
 (0)