Skip to content

Commit

Permalink
On windows handle the long paths in realpathSync.native
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Aug 15, 2022
1 parent 9f7c0cb commit b73d93b
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 b73d93b

Please sign in to comment.