Skip to content

Commit 48f381d

Browse files
authored
fs: only show deprecation warning when error code matches
PR-URL: #56549 Refs: #55753 Reviewed-By: Jacob Smith <[email protected]>
1 parent 0d92ce4 commit 48f381d

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
@@ -278,8 +278,8 @@ let showExistsDeprecation = true;
278278
function existsSync(path) {
279279
try {
280280
path = getValidatedPath(path);
281-
} catch {
282-
if (showExistsDeprecation) {
281+
} catch (err) {
282+
if (showExistsDeprecation && err?.code === 'ERR_INVALID_ARG_TYPE') {
283283
process.emitWarning(
284284
'Passing invalid argument types to fs.existsSync is deprecated', 'DeprecationWarning', 'DEP0187',
285285
);

0 commit comments

Comments
 (0)