From 6f621761e317d8757d51266b684bdddcf867418d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 10 Jan 2025 13:07:44 +0100 Subject: [PATCH] fs: only show deprecation warning when error code matches --- lib/fs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index e2996ba9ca4ef6..1a72361e8cf425 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -282,8 +282,8 @@ let showExistsDeprecation = true; function existsSync(path) { try { path = getValidatedPath(path); - } catch { - if (showExistsDeprecation) { + } catch (err) { + if (showExistsDeprecation && err?.code === 'ERR_INVALID_ARG_TYPE') { process.emitWarning( 'Passing invalid argument types to fs.existsSync is deprecated', 'DeprecationWarning', 'DEP0187', );