Fix issue with trailing directory separator not present if symlink wasnt detected by program (#55865)

This commit is contained in:
Sheetal Nandi
2023-09-25 16:52:27 -07:00
committed by GitHub
parent d7b4cee7df
commit 4ec809da37
6 changed files with 2242 additions and 10 deletions
+13 -4
View File
@@ -8802,9 +8802,15 @@ export function hasZeroOrOneAsteriskCharacter(str: string): boolean {
/** @internal */
export interface SymlinkedDirectory {
/** Matches the casing returned by `realpath`. Used to compute the `realpath` of children. */
/**
* Matches the casing returned by `realpath`. Used to compute the `realpath` of children.
* Always has trailing directory separator
*/
real: string;
/** toPath(real). Stored to avoid repeated recomputation. */
/**
* toPath(real). Stored to avoid repeated recomputation.
* Always has trailing directory separator
*/
realPath: Path;
}
@@ -8859,7 +8865,7 @@ export function createSymlinkCache(cwd: string, getCanonicalFileName: GetCanonic
if (!containsIgnoredPath(symlinkPath)) {
symlinkPath = ensureTrailingDirectorySeparator(symlinkPath);
if (real !== false && !symlinkedDirectories?.has(symlinkPath)) {
(symlinkedDirectoriesByRealpath ||= createMultiMap()).add(ensureTrailingDirectorySeparator(real.realPath), symlink);
(symlinkedDirectoriesByRealpath ||= createMultiMap()).add(real.realPath, symlink);
}
(symlinkedDirectories || (symlinkedDirectories = new Map())).set(symlinkPath, real);
}
@@ -8882,7 +8888,10 @@ export function createSymlinkCache(cwd: string, getCanonicalFileName: GetCanonic
if (commonResolved && commonOriginal) {
cache.setSymlinkedDirectory(
commonOriginal,
{ real: commonResolved, realPath: toPath(commonResolved, cwd, getCanonicalFileName) },
{
real: ensureTrailingDirectorySeparator(commonResolved),
realPath: ensureTrailingDirectorySeparator(toPath(commonResolved, cwd, getCanonicalFileName)),
},
);
}
}