Skip to content

Commit

Permalink
On windows handle the long paths in realpathSync.native (#50306)
Browse files Browse the repository at this point in the history
Fixes #49470
  • Loading branch information
sheetalkamat committed Aug 15, 2022
1 parent e989d84 commit 9c1baee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compiler/sys.ts
Expand Up @@ -1440,7 +1440,7 @@ namespace ts {

const platform: string = _os.platform();
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
const realpathSync = _fs.realpathSync.native ?? _fs.realpathSync;
const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;

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

function fsRealPathHandlingLongPath(path: string): string {
return path.length < 260 ? _fs.realpathSync.native(path) : _fs.realpathSync(path);
}

function realpath(path: string): string {
try {
return realpathSync(path);
return fsRealpath(path);
}
catch {
return path;
Expand Down

0 comments on commit 9c1baee

Please sign in to comment.