From 260c5e341da207f21df521af7f5e6cf6e3987482 Mon Sep 17 00:00:00 2001 From: ddorando <87425418+ddorando@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:10:30 +0300 Subject: [PATCH] fs.statSync(fs.realpathSync()) for fileExistsSync --- src/utils.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 275418b..c84532a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -147,10 +147,9 @@ export function fileExistsSync(path: string): boolean { throw new Error("Arg 'path' must not be empty") } - const fd = fs.openSync(path, 'r') let stats: fs.Stats try { - stats = fs.fstatSync(fd) + stats = fs.statSync(fs.realpathSync(path)) } catch (error) { if (hasErrorCode(error) && error.code === 'ENOENT') { return false @@ -161,8 +160,6 @@ export function fileExistsSync(path: string): boolean { error )}` ) - } finally { - fs.closeSync(fd) } if (!stats.isDirectory()) {