mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Merge pull request #19058 from Microsoft/whenWatchesFail
Swallow the directory watcher exceptions and ignore them
This commit is contained in:
@@ -14012,7 +14012,7 @@ namespace ts {
|
||||
*/
|
||||
function isUnhyphenatedJsxName(name: string | __String) {
|
||||
// - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers
|
||||
return (name as string).indexOf("-") < 0;
|
||||
return !stringContains(name as string, "-");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1648,7 +1648,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isUrl(path: string) {
|
||||
return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1;
|
||||
return path && !isRootedDiskPath(path) && stringContains(path, "://");
|
||||
}
|
||||
|
||||
export function pathIsRelative(path: string): boolean {
|
||||
@@ -1917,8 +1917,12 @@ namespace ts {
|
||||
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
export function stringContains(str: string, substring: string): boolean {
|
||||
return str.indexOf(substring) !== -1;
|
||||
}
|
||||
|
||||
export function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
return stringContains(getBaseFileName(fileName), ".");
|
||||
}
|
||||
|
||||
export function fileExtensionIs(path: string, extension: string): boolean {
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace ts {
|
||||
|
||||
function hasInternalAnnotation(range: CommentRange) {
|
||||
const comment = currentText.substring(range.pos, range.end);
|
||||
return comment.indexOf("@internal") >= 0;
|
||||
return stringContains(comment, "@internal");
|
||||
}
|
||||
|
||||
function stripInternal(node: Node) {
|
||||
|
||||
@@ -1226,7 +1226,7 @@ namespace ts {
|
||||
// check if numeric literal is a decimal literal that was originally written with a dot
|
||||
const text = getLiteralTextOfNode(<LiteralExpression>expression);
|
||||
return !expression.numericLiteralFlags
|
||||
&& text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0;
|
||||
&& !stringContains(text, tokenToString(SyntaxKind.DotToken));
|
||||
}
|
||||
else if (isPropertyAccessExpression(expression) || isElementAccessExpression(expression)) {
|
||||
// check if constant enum value is integer
|
||||
|
||||
@@ -1061,7 +1061,7 @@ namespace ts {
|
||||
export function getPackageNameFromAtTypesDirectory(mangledName: string): string {
|
||||
const withoutAtTypePrefix = removePrefix(mangledName, "@types/");
|
||||
if (withoutAtTypePrefix !== mangledName) {
|
||||
return withoutAtTypePrefix.indexOf(mangledScopedPackageSeparator) !== -1 ?
|
||||
return stringContains(withoutAtTypePrefix, mangledScopedPackageSeparator) ?
|
||||
"@" + withoutAtTypePrefix.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
|
||||
withoutAtTypePrefix;
|
||||
}
|
||||
|
||||
@@ -329,17 +329,14 @@ namespace ts {
|
||||
let dir = getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()));
|
||||
let dirPath = getDirectoryPath(failedLookupLocationPath);
|
||||
|
||||
// If the directory is node_modules use it to watch
|
||||
if (isNodeModulesDirectory(dirPath)) {
|
||||
return { dir, dirPath };
|
||||
// If directory path contains node module, get the most parent node_modules directory for watching
|
||||
while (stringContains(dirPath, "/node_modules/")) {
|
||||
dir = getDirectoryPath(dir);
|
||||
dirPath = getDirectoryPath(dirPath);
|
||||
}
|
||||
|
||||
// If directory path contains node module, get the node_modules directory for watching
|
||||
if (dirPath.indexOf("/node_modules/") !== -1) {
|
||||
while (!isNodeModulesDirectory(dirPath)) {
|
||||
dir = getDirectoryPath(dir);
|
||||
dirPath = getDirectoryPath(dirPath);
|
||||
}
|
||||
// If the directory is node_modules use it to watch
|
||||
if (isNodeModulesDirectory(dirPath)) {
|
||||
return { dir, dirPath };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user