MCPcopy Create free account
hub / github.com/nodejs/node / getDirectoryToWatchFailedLookupLocation

Function getDirectoryToWatchFailedLookupLocation

test/fixtures/snapshot/typescript.js:121539–121563  ·  view source on GitHub ↗
(failedLookupLocation, failedLookupLocationPath)

Source from the content-addressed store, hash-verified

121537 return ts.endsWith(dirPath, "/node_modules/@types");
121538 }
121539 function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
121540 if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
121541 // Ensure failed look up is normalized path
121542 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
121543 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
121544 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
121545 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath));
121546 if (failedLookupPathSplit.length > rootSplitLength + 1) {
121547 // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution
121548 return {
121549 dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
121550 dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
121551 };
121552 }
121553 else {
121554 // Always watch root directory non recursively
121555 return {
121556 dir: rootDir,
121557 dirPath: rootPath,
121558 nonRecursive: false
121559 };
121560 }
121561 }
121562 return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
121563 }
121564 function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
121565 // If directory path contains node module, get the most parent node_modules directory for watching
121566 while (ts.pathContainsNodeModules(dirPath)) {

Calls 7

isInDirectoryPathFunction · 0.85
assertMethod · 0.80
concatMethod · 0.80
sliceMethod · 0.65
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected