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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Masashi Hirano <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
  • 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.