diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a5330d807cddc..da38d389f212f 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1266,7 +1266,6 @@ namespace ts { let activeSession: import("inspector").Session | "stopping" | undefined; let profilePath = "./profile.cpuprofile"; - let hitSystemWatcherLimit = false; const Buffer: { new (input: string, encoding?: string): any; @@ -1620,12 +1619,6 @@ namespace ts { options = { persistent: true }; } } - - if (hitSystemWatcherLimit) { - sysLog(`sysLog:: ${fileOrDirectory}:: Defaulting to fsWatchFile`); - return watchPresentFileSystemEntryWithFsWatchFile(); - } - try { const presentWatcher = _fs.watch( fileOrDirectory, @@ -1642,8 +1635,6 @@ namespace ts { // Catch the exception and use polling instead // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile - hitSystemWatcherLimit ||= e.code === "ENOSPC"; - sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -1665,6 +1656,7 @@ namespace ts { * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile(): FileWatcher { + sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`); return watchFile( fileOrDirectory, createFileWatcherCallback(callback), @@ -1804,7 +1796,7 @@ namespace ts { } function readDirectory(path: string, extensions?: readonly string[], excludes?: readonly string[], includes?: readonly string[], depth?: number): string[] { - return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath, directoryExists); + return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath); } function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ea71b61acc8ff..9c706c6f61814 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6638,7 +6638,7 @@ namespace ts { } /** @param path directory of the tsconfig.json */ - export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[] { + export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); @@ -6654,9 +6654,7 @@ namespace ts { const visited = new Map(); const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames); for (const basePath of patterns.basePaths) { - if (directoryExists(basePath)) { - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); - } + visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); } return flatten(results); diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index c6b9df2c3e3b5..adbf9f1287b1b 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -184,7 +184,7 @@ namespace ts { const rootResult = tryReadDirectory(rootDir, rootDirPath); let rootSymLinkResult: FileSystemEntries | undefined; if (rootResult !== undefined) { - return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists); + return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory!(rootDir, extensions, excludes, includes, depth); diff --git a/src/harness/fakesHosts.ts b/src/harness/fakesHosts.ts index 898cfc048c32e..58b29a4c7ef98 100644 --- a/src/harness/fakesHosts.ts +++ b/src/harness/fakesHosts.ts @@ -95,7 +95,7 @@ namespace fakes { } public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] { - return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path), path => this.directoryExists(path)); + return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path)); } public getAccessibleFileSystemEntries(path: string): ts.FileSystemEntries { diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 77e3741d1fce8..62c6cd042ef93 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -922,7 +922,7 @@ interface Array { length: number; [n: number]: T; }` }); } return { directories, files }; - }, path => this.realpath(path), path => this.directoryExists(path)); + }, path => this.realpath(path)); } createHash(s: string): string {