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

Function guessDirectorySymlink

test/fixtures/snapshot/typescript.js:20452–20465  ·  view source on GitHub ↗
(a, b, cwd, getCanonicalFileName)

Source from the content-addressed store, hash-verified

20450 }
20451 ts.createSymlinkCache = createSymlinkCache;
20452 function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
20453 var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd));
20454 var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd));
20455 var isDirectory = false;
20456 while (aParts.length >= 2 && bParts.length >= 2 &&
20457 !isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
20458 !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
20459 getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
20460 aParts.pop();
20461 bParts.pop();
20462 isDirectory = true;
20463 }
20464 return isDirectory ? [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)] : undefined;
20465 }
20466 // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
20467 // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked.
20468 function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {

Callers 1

processResolutionFunction · 0.85

Calls 3

getCanonicalFileNameFunction · 0.85
popMethod · 0.80

Tested by

no test coverage detected