Skip to content

Commit 0b0703a

Browse files
authored
fix: gracefully handle invalid "watchOptions.ignored" (#595)
Closes: #594
1 parent 60cc369 commit 0b0703a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/watch/InclusiveNodeWatchFileSystem.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ function createIsIgnored(
1212
ignored: WatchFileSystemOptions['ignored'] | undefined
1313
): (path: string) => boolean {
1414
const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
15-
const ignoredFunctions = ignoredPatterns.map((pattern) =>
16-
pattern instanceof RegExp
17-
? (path: string) => pattern.test(path)
18-
: (path: string) => minimatch(path, pattern)
19-
);
15+
const ignoredFunctions = ignoredPatterns
16+
// sanitize patterns - see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/594
17+
.filter((pattern) => typeof pattern === 'string' || pattern instanceof RegExp)
18+
.map((pattern) =>
19+
pattern instanceof RegExp
20+
? (path: string) => pattern.test(path)
21+
: (path: string) => minimatch(path, pattern)
22+
);
2023
ignoredFunctions.push((path: string) =>
2124
BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`))
2225
);

0 commit comments

Comments
 (0)