From 851596ad8991aa21e5db3ddc747da157ad94e7fb Mon Sep 17 00:00:00 2001 From: Rob Stolarz Date: Tue, 29 Nov 2022 17:33:30 -0800 Subject: [PATCH] Skip stat call / throwing when files don't exist --- src/filesystem.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/filesystem.ts b/src/filesystem.ts index bdac28b..d4f60b4 100644 --- a/src/filesystem.ts +++ b/src/filesystem.ts @@ -33,6 +33,10 @@ export interface ReadJsonAsync { } export function fileExistsSync(path: string): boolean { + // If the file doesn't exist, avoid throwing an exception over the native barrier for every miss + if (!fs.existsSync(path)) { + return false; + } try { const stats = fs.statSync(path); return stats.isFile();