MCPcopy Index your code
hub / github.com/nodejs/node / fileOrDirectoryExistsUsingSource

Function fileOrDirectoryExistsUsingSource

test/fixtures/snapshot/typescript.js:119367–119398  ·  view source on GitHub ↗
(fileOrDirectory, isFile)

Source from the content-addressed store, hash-verified

119365 });
119366 }
119367 function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
119368 var _a;
119369 var fileOrDirectoryExistsUsingSource = isFile ?
119370 function (file) { return fileExistsIfProjectReferenceDts(file); } :
119371 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
119372 // Check current directory or file
119373 var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
119374 if (result !== undefined)
119375 return result;
119376 var symlinkCache = host.getSymlinkCache();
119377 var symlinkedDirectories = symlinkCache.getSymlinkedDirectories();
119378 if (!symlinkedDirectories)
119379 return false;
119380 var fileOrDirectoryPath = host.toPath(fileOrDirectory);
119381 if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
119382 return false;
119383 if (isFile && ((_a = symlinkCache.getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.has(fileOrDirectoryPath)))
119384 return true;
119385 // If it contains node_modules check if its one of the symlinked path we know of
119386 return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
119387 var directoryPath = _a[0], symlinkedDirectory = _a[1];
119388 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
119389 return undefined;
119390 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
119391 if (isFile && result) {
119392 // Store the real path for the file'
119393 var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
119394 symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), "")));
119395 }
119396 return result;
119397 }) || false;
119398 }
119399 }
119400 /*@internal*/
119401 ts.emitSkippedWithNoDiagnostics = { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };

Callers 2

fileExistsFunction · 0.85

Calls 5

concatMethod · 0.80
hasMethod · 0.65
entriesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…