Skip to content

Commit 463e585

Browse files
aduh95RafaelGSS
authored andcommitted
fs: only show deprecation warning when error code matches
PR-URL: #56549 Refs: #55753 Reviewed-By: Jacob Smith <[email protected]>
1 parent 2904e58 commit 463e585

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/fs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ let showExistsDeprecation = true;
282282
function existsSync(path) {
283283
try {
284284
path = getValidatedPath(path);
285-
} catch {
286-
if (showExistsDeprecation) {
285+
} catch (err) {
286+
if (showExistsDeprecation && err?.code === 'ERR_INVALID_ARG_TYPE') {
287287
process.emitWarning(
288288
'Passing invalid argument types to fs.existsSync is deprecated', 'DeprecationWarning', 'DEP0187',
289289
);

0 commit comments

Comments
 (0)