Skip to content

Commit ccfc09d

Browse files
TypeScript Botsheetalkamat
TypeScript Bot
andauthored
Cherry-pick PR #50306 into release-4.8 (#50324)
Component commits: b73d93b On windows handle the long paths in realpathSync.native Fixes #49470 Co-authored-by: Sheetal Nandi <[email protected]>
1 parent 745f958 commit ccfc09d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/compiler/sys.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ namespace ts {
14401440

14411441
const platform: string = _os.platform();
14421442
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
1443-
const realpathSync = _fs.realpathSync.native ?? _fs.realpathSync;
1443+
const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
14441444

14451445
const fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
14461446
const getCurrentDirectory = memoize(() => process.cwd());
@@ -1889,9 +1889,13 @@ namespace ts {
18891889
return getAccessibleFileSystemEntries(path).directories.slice();
18901890
}
18911891

1892+
function fsRealPathHandlingLongPath(path: string): string {
1893+
return path.length < 260 ? _fs.realpathSync.native(path) : _fs.realpathSync(path);
1894+
}
1895+
18921896
function realpath(path: string): string {
18931897
try {
1894-
return realpathSync(path);
1898+
return fsRealpath(path);
18951899
}
18961900
catch {
18971901
return path;

0 commit comments

Comments
 (0)