From 148254744134793cd6556c9749658f3872b03d00 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 25 Feb 2019 22:28:35 +0100 Subject: [PATCH] process: add --pending-deprecation to `process.binding()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Print a deprecation warning for `process.binding()` when using `--pending-deprecation`. PR-URL: https://github.com/nodejs/node/pull/26500 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Gus Caplan Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Minwoo Jung Reviewed-By: Michaël Zasso Reviewed-By: Masashi Hirano Reviewed-By: Ruben Bridgewater Reviewed-By: Tobias Nießen Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Anto Aravinth --- doc/api/deprecations.md | 5 ++++- lib/internal/bootstrap/pre_execution.js | 6 ++++++ test/parallel/test-err-name-deprecation.js | 15 +++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 24d4a3ea32058e..59f19e5b549b32 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2134,9 +2134,12 @@ changes: - version: v10.9.0 pr-url: https://github.com/nodejs/node/pull/22004 description: Documentation-only deprecation. + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/26500 + description: Added support for `--pending-deprecation`. --> -Type: Documentation-only +Type: Documentation-only (supports [`--pending-deprecation`][]) `process.binding()` is for use by Node.js internal code only. diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 30c0d89a4a4911..936dc4673c1c2a 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -195,6 +195,12 @@ function initializeDeprecations() { value: noBrowserGlobals }); } + + if (pendingDeprecation) { + process.binding = deprecate(process.binding, + 'process.binding() is deprecated. ' + + 'Please use public APIs instead.', 'DEP0111'); + } } function setupChildProcessIpcChannel() { diff --git a/test/parallel/test-err-name-deprecation.js b/test/parallel/test-err-name-deprecation.js index d9af7e3804ec4a..58dff38364c818 100644 --- a/test/parallel/test-err-name-deprecation.js +++ b/test/parallel/test-err-name-deprecation.js @@ -3,11 +3,14 @@ const common = require('../common'); // Flags: --pending-deprecation -common.expectWarning( - 'DeprecationWarning', - 'Directly calling process.binding(\'uv\').errname() is being ' + - 'deprecated. Please make sure to use util.getSystemErrorName() instead.', - 'DEP0119' -); +common.expectWarning({ + DeprecationWarning: [ + ['process.binding() is deprecated. Please use public APIs instead.', + 'DEP0111'], + ['Directly calling process.binding(\'uv\').errname() is being ' + + 'deprecated. Please make sure to use util.getSystemErrorName() instead.', + 'DEP0119'] + ] +}); process.binding('uv').errname(-1);