Skip to content

Commit 207612c

Browse files
joyeecheungaddaleax
authored andcommitted
lib: remove internalBinding('config').pendingDeprecation
Instead use `require('internal/options').getOptionValue('--pending-deprecation')` PR-URL: #24962 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Backport-PR-URL: #25446
1 parent d197105 commit 207612c

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

lib/buffer.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ const {
5555
isArrayBufferView,
5656
isUint8Array
5757
} = require('internal/util/types');
58-
const {
59-
pendingDeprecation
60-
} = internalBinding('config');
58+
6159
const {
6260
formatProperty,
6361
kObjectType
@@ -150,7 +148,7 @@ const bufferWarning = 'Buffer() is deprecated due to security and usability ' +
150148
function showFlaggedDeprecation() {
151149
if (bufferWarningAlreadyEmitted ||
152150
++nodeModulesCheckCounter > 10000 ||
153-
(!pendingDeprecation &&
151+
(!require('internal/options').getOptionValue('--pending-deprecation') &&
154152
isInsideNodeModules())) {
155153
// We don't emit a warning, because we either:
156154
// - Already did so, or

lib/internal/bootstrap/node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function startup() {
176176
{
177177
// Install legacy getters on the `util` binding for typechecking.
178178
// TODO(addaleax): Turn into a full runtime deprecation.
179-
const { pendingDeprecation } = internalBinding('config');
179+
const pendingDeprecation = getOptionValue('--pending-deprecation');
180180
const utilBinding = internalBinding('util');
181181
const types = internalBinding('types');
182182
for (const name of [

src/node_config.cc

-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ static void Initialize(Local<Object> target,
7777
if (env->options()->experimental_repl_await)
7878
READONLY_TRUE_PROPERTY(target, "experimentalREPLAwait");
7979

80-
if (env->options()->pending_deprecation)
81-
READONLY_TRUE_PROPERTY(target, "pendingDeprecation");
82-
8380
if (env->options()->expose_internals)
8481
READONLY_TRUE_PROPERTY(target, "exposeInternals");
8582

test/parallel/test-pending-deprecation.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
11
'use strict';
22

3-
// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both
4-
// set the process.binding('config').pendingDeprecation flag that is
5-
// used to determine if pending deprecation messages should be shown.
6-
// The test is performed by launching two child processes that run
3+
// Flags: --expose-internals
4+
// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both set the
5+
// `require('internal/options').getOptionValue('--pending-deprecation')`
6+
// flag that is used to determine if pending deprecation messages should be
7+
// shown. The test is performed by launching two child processes that run
78
// this same test script with different arguments. If those exit with
89
// code 0, then the test passes. If they don't, it fails.
910

11+
// TODO(joyeecheung): instead of testing internals, test the actual features
12+
// pending deprecations.
13+
1014
const common = require('../common');
1115

1216
const assert = require('assert');
13-
const config = process.binding('config');
1417
const fork = require('child_process').fork;
18+
const { getOptionValue } = require('internal/options');
1519

1620
function message(name) {
17-
return `${name} did not set the process.binding('config').` +
18-
'pendingDeprecation flag.';
21+
return `${name} did not affect getOptionValue('--pending-deprecation')`;
1922
}
2023

2124
switch (process.argv[2]) {
2225
case 'env':
2326
case 'switch':
24-
assert.strictEqual(config.pendingDeprecation, true);
27+
assert.strictEqual(
28+
getOptionValue('--pending-deprecation'),
29+
true
30+
);
2531
break;
2632
default:
2733
// Verify that the flag is off by default.
2834
const envvar = process.env.NODE_PENDING_DEPRECATION;
29-
assert.strictEqual(config.pendingDeprecation, envvar && envvar[0] === '1');
35+
assert.strictEqual(
36+
getOptionValue('--pending-deprecation'),
37+
!!(envvar && envvar[0] === '1')
38+
);
3039

3140
// Test the --pending-deprecation command line switch.
3241
fork(__filename, ['switch'], {
33-
execArgv: ['--pending-deprecation'],
42+
execArgv: ['--pending-deprecation', '--expose-internals'],
3443
silent: true
3544
}).on('exit', common.mustCall((code) => {
3645
assert.strictEqual(code, 0, message('--pending-deprecation'));
3746
}));
3847

3948
// Test the --pending_deprecation command line switch.
4049
fork(__filename, ['switch'], {
41-
execArgv: ['--pending_deprecation'],
50+
execArgv: ['--pending_deprecation', '--expose-internals'],
4251
silent: true
4352
}).on('exit', common.mustCall((code) => {
4453
assert.strictEqual(code, 0, message('--pending_deprecation'));
@@ -47,6 +56,7 @@ switch (process.argv[2]) {
4756
// Test the NODE_PENDING_DEPRECATION environment var.
4857
fork(__filename, ['env'], {
4958
env: Object.assign({}, process.env, { NODE_PENDING_DEPRECATION: 1 }),
59+
execArgv: ['--expose-internals'],
5060
silent: true
5161
}).on('exit', common.mustCall((code) => {
5262
assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION'));

0 commit comments

Comments
 (0)