Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On windows handle the long paths in realpathSync.native #50306

Merged
merged 1 commit into from Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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