Skip to content

Commit

Permalink
Cherry-pick PR #50306 into release-4.8 (#50324)
Browse files Browse the repository at this point in the history
Component commits:
b73d93b On windows handle the long paths in realpathSync.native Fixes #49470

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
  • Loading branch information
TypeScript Bot and sheetalkamat authored Aug 16, 2022
1 parent 745f958 commit ccfc09d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
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 ccfc09d

Please sign in to comment.