Skip to content

Commit 1cba9b5

Browse files
authored
Merge pull request #223 from allenylzhou/allenylzhou/ignore-node-modules
Ignore node_modules hoisted above project root
2 parents 5c468af + b0c3e25 commit 1cba9b5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/utilities/compile.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function buildWatchHooks(project, ts, callbacks) {
8080
}
8181

8282
let dir = getCanonicalCapitalization(path.resolve(rawDir));
83-
let ignored = buildIgnoreRegex(dir, ignorePatterns);
83+
let ignored = buildIgnoreDefs(dir, ignorePatterns);
8484
let watcher = chokidar.watch(dir, { ignored, ignoreInitial: true });
8585
debug(`watching directory %s %o`, dir, { ignored });
8686

@@ -105,10 +105,13 @@ function buildWatchHooks(project, ts, callbacks) {
105105
});
106106
}
107107

108-
function buildIgnoreRegex(rootDir, patterns) {
108+
function buildIgnoreDefs(rootDir, patterns) {
109109
let base = escapeRegex(rootDir);
110110
let sep = `[/\\\\]`;
111-
return new RegExp(`^${base}${sep}(${patterns.join('|')})${sep}`, 'i');
111+
return [
112+
'**/node_modules/**',
113+
new RegExp(`^${base}${sep}(${patterns.join('|')})${sep}`, 'i')
114+
];
112115
}
113116

114117
// On case-insensitive file systems, tsc will normalize paths to be all lowercase,

0 commit comments

Comments
 (0)