From 56f9d5e4e3372d5cc0738f3ec0ea77e97dd75f25 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 27 Oct 2020 15:55:19 -0700 Subject: [PATCH] Check lstat before calling realpath The only thing we're using realpath for is to resolve symlinks and most files and directories are not symlinks. This change skips the expensive realpath call for non-symlinks. --- src/compiler/sys.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index efa51678f4da0..c7d360f577662 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1697,6 +1697,9 @@ namespace ts { function realpath(path: string): string { try { + if (!_fs.lstatSync(path).isSymbolicLink()) { + return path; + } return _fs.realpathSync(path); } catch {