mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
+2
-10
@@ -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 {
|
||||
|
||||
@@ -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<string, true>();
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -922,7 +922,7 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
});
|
||||
}
|
||||
return { directories, files };
|
||||
}, path => this.realpath(path), path => this.directoryExists(path));
|
||||
}, path => this.realpath(path));
|
||||
}
|
||||
|
||||
createHash(s: string): string {
|
||||
|
||||
Reference in New Issue
Block a user