From 9af6631a5fe52960b4dfb1f8f773eb80e6e27bdb 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 113986918f046e..1c660fef0f369a 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2110,9 +2110,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 d295a5fec7e286..3e64540aa32ae2 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -149,6 +149,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);