Skip to content

Commit

Permalink
process: add --pending-deprecation to process.binding()
Browse files Browse the repository at this point in the history
Print a deprecation warning for `process.binding()` when using
`--pending-deprecation`.

PR-URL: #26500
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
  • Loading branch information
addaleax authored and BridgeAR committed Mar 14, 2019
1 parent fdad4d2 commit ceebbfb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions lib/internal/bootstrap/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 9 additions & 6 deletions test/parallel/test-err-name-deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ const common = require('../common');

// Flags: --pending-deprecation

common.expectWarning(
'DeprecationWarning',
'Directly calling process.binding(\'uv\').errname(<val>) 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(<val>) is being ' +
'deprecated. Please make sure to use util.getSystemErrorName() instead.',
'DEP0119']
]
});

process.binding('uv').errname(-1);

0 comments on commit ceebbfb

Please sign in to comment.