Ignore anything starting with ".git"

Fixes #29782
This commit is contained in:
Sheetal Nandi
2019-03-06 15:00:26 -08:00
parent 79a1f29727
commit ec2ee9ff3a
5 changed files with 29 additions and 10 deletions
+7 -4
View File
@@ -326,6 +326,9 @@ namespace ts {
: FileWatcherEventKind.Changed;
}
/*@internal*/
export const ignoredPaths = ["/node_modules/.", "/.git"];
/*@internal*/
export interface RecursiveDirectoryWatcherHost {
watchDirectory: HostWatchDirectory;
@@ -371,7 +374,7 @@ namespace ts {
else {
directoryWatcher = {
watcher: host.watchDirectory(dirName, fileName => {
if (isInNodeModulesStartingWithDot(fileName)) return;
if (isIgnoredPath(fileName)) return;
// Call the actual callback
callbackCache.forEach((callbacks, rootDirName) => {
@@ -428,7 +431,7 @@ namespace ts {
const childFullName = getNormalizedAbsolutePath(child, parentDir);
// Filter our the symbolic link directories since those arent included in recursive watch
// which is same behaviour when recursive: true is passed to fs.watch
return !isInNodeModulesStartingWithDot(childFullName) && filePathComparer(childFullName, normalizePath(host.realpath(childFullName))) === Comparison.EqualTo ? childFullName : undefined;
return !isIgnoredPath(childFullName) && filePathComparer(childFullName, normalizePath(host.realpath(childFullName))) === Comparison.EqualTo ? childFullName : undefined;
}) : emptyArray,
existingChildWatches,
(child, childWatcher) => filePathComparer(child, childWatcher.dirName),
@@ -455,8 +458,8 @@ namespace ts {
}
}
function isInNodeModulesStartingWithDot(path: string) {
return isInPath(path, "/node_modules/.");
function isIgnoredPath(path: string) {
return some(ignoredPaths, searchPath => isInPath(path, searchPath));
}
function isInPath(path: string, searchPath: string) {