fs: only show deprecation warning when error code matches

PR-URL: https://github.com/nodejs/node/pull/56549
Refs: https://github.com/nodejs/node/pull/55753
Reviewed-By: Jacob Smith <jacob@frende.me>
This commit is contained in:
Antoine du Hamel
2025-02-28 11:46:11 +01:00
committed by GitHub
parent 0d92ce497b
commit 48f381d309

View File

@@ -278,8 +278,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',
);