Skip to content

Commit 88a5449

Browse files
Masashi HiranoBridgeAR
Masashi Hirano
authored andcommitted
src,lib: make process.binding('config') internal
PR-URL: #23400 Refs: #22160 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 5a853a0 commit 88a5449

16 files changed

+24
-18
lines changed

lib/buffer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const {
5050
} = require('internal/util/types');
5151
const {
5252
pendingDeprecation
53-
} = process.binding('config');
53+
} = internalBinding('config');
5454
const {
5555
ERR_BUFFER_OUT_OF_BOUNDS,
5656
ERR_OUT_OF_RANGE,
@@ -1067,7 +1067,7 @@ Buffer.prototype.swap64 = function swap64() {
10671067
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
10681068

10691069
let transcode;
1070-
if (process.binding('config').hasIntl) {
1070+
if (internalBinding('config').hasIntl) {
10711071
const {
10721072
icuErrName,
10731073
transcode: _transcode

lib/crypto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const pendingDeprecation = getOptionValue('--pending-deprecation');
4040
const {
4141
fipsMode,
4242
fipsForced
43-
} = process.binding('config');
43+
} = internalBinding('config');
4444
const { getFipsCrypto, setFipsCrypto } = internalBinding('crypto');
4545
const {
4646
randomBytes,

lib/internal/async_hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function fatalError(e) {
107107
Error.captureStackTrace(o, fatalError);
108108
process._rawDebug(o.stack);
109109
}
110-
if (process.binding('config').shouldAbortOnUncaughtException) {
110+
if (internalBinding('config').shouldAbortOnUncaughtException) {
111111
process.abort();
112112
}
113113
process.exit(1);

lib/internal/bootstrap/loaders.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
'buffer',
8080
'cares_wrap',
8181
'constants',
82+
'config',
8283
'contextify',
8384
'crypto',
8485
'fs_event_wrap',
@@ -164,7 +165,7 @@
164165
NativeModule._source = getInternalBinding('natives');
165166
NativeModule._cache = {};
166167

167-
const config = getBinding('config');
168+
const config = getInternalBinding('config');
168169

169170
// Think of this as module.exports in this file even though it is not
170171
// written in CommonJS style.

lib/internal/bootstrap/node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
{
178178
// Install legacy getters on the `util` binding for typechecking.
179179
// TODO(addaleax): Turn into a full runtime deprecation.
180-
const { pendingDeprecation } = process.binding('config');
180+
const { pendingDeprecation } = internalBinding('config');
181181
const utilBinding = internalBinding('util');
182182
const types = internalBinding('types');
183183
for (const name of [
@@ -665,7 +665,7 @@
665665
}
666666

667667
function setupProcessICUVersions() {
668-
const icu = process.binding('config').hasIntl ?
668+
const icu = internalBinding('config').hasIntl ?
669669
internalBinding('icu') : undefined;
670670
if (!icu) return; // no Intl/ICU: nothing to add here.
671671
// With no argument, getVersion() returns a comma separated list

lib/internal/encoding.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ Object.defineProperties(
342342
} });
343343

344344
const TextDecoder =
345-
process.binding('config').hasIntl ?
345+
internalBinding('config').hasIntl ?
346346
makeTextDecoderICU() :
347347
makeTextDecoderJS();
348348

lib/internal/inspector_async_hook.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let config;
1212

1313
function lazyHookCreation() {
1414
const { createHook } = require('async_hooks');
15-
config = process.binding('config');
15+
config = internalBinding('config');
1616

1717
hook = createHook({
1818
init(asyncId, type, triggerAsyncId, resource) {

lib/internal/print_help.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ for (const key of Object.keys(types))
99

1010
// Environment variables are parsed ad-hoc throughout the code base,
1111
// so we gather the documentation here.
12-
const { hasIntl, hasSmallICU, hasNodeOptions } = process.binding('config');
12+
const { hasIntl, hasSmallICU, hasNodeOptions } = internalBinding('config');
1313
const envVars = new Map([
1414
['NODE_DEBUG', { helpText: "','-separated list of core modules that " +
1515
'should print debug information' }],

lib/internal/process/warning.js

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

3-
const config = process.binding('config');
3+
const config = internalBinding('config');
44
const prefix = `(${process.release.name}:${process.pid}) `;
55
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
66

lib/internal/readline.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CSI.kClearToEnd = CSI`0K`;
3030
CSI.kClearLine = CSI`2K`;
3131
CSI.kClearScreenDown = CSI`0J`;
3232

33-
if (process.binding('config').hasIntl) {
33+
if (internalBinding('config').hasIntl) {
3434
const icu = internalBinding('icu');
3535
getStringWidth = function getStringWidth(str, options) {
3636
options = options || {};

lib/trace_events.js

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

3-
const { hasTracing } = process.binding('config');
3+
const { hasTracing } = internalBinding('config');
44
const kHandle = Symbol('handle');
55
const kEnabled = Symbol('enabled');
66
const kCategories = Symbol('categories');

lib/url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
const { toASCII } = process.binding('config').hasIntl ?
24+
const { toASCII } = internalBinding('config').hasIntl ?
2525
internalBinding('icu') : require('punycode');
2626

2727
const { hexTable } = require('internal/querystring');

src/node_config.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ static void Initialize(Local<Object> target,
112112

113113
} // namespace node
114114

115-
NODE_BUILTIN_MODULE_CONTEXT_AWARE(config, node::Initialize)
115+
NODE_MODULE_CONTEXT_AWARE_INTERNAL(config, node::Initialize)

test/parallel/test-icu-data-dir.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// Flags: --expose-internals
12
'use strict';
3+
const { internalBinding } = require('internal/test/binding');
24
const common = require('../common');
35
const os = require('os');
46

5-
const { hasSmallICU } = process.binding('config');
7+
const { hasSmallICU } = internalBinding('config');
68
if (!(common.hasIntl && hasSmallICU))
79
common.skip('missing Intl');
810

test/parallel/test-internal-modules-expose.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
require('../common');
55
const assert = require('assert');
6-
const config = process.binding('config');
6+
const { internalBinding } = require('internal/test/binding');
7+
const config = internalBinding('config');
78

89
console.log(config, process.argv);
910

test/parallel/test-readline-position.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// Flags: --expose-internals
12
'use strict';
3+
const { internalBinding } = require('internal/test/binding');
24
require('../common');
35
const { PassThrough } = require('stream');
46
const readline = require('readline');
@@ -23,7 +25,7 @@ const ctrlU = { ctrl: true, name: 'u' };
2325
// The non-ICU JS implementation of character width calculation is only aware
2426
// of the wide/narrow distinction. Only test these more advanced cases when
2527
// ICU is available.
26-
if (process.binding('config').hasIntl) {
28+
if (internalBinding('config').hasIntl) {
2729
tests.push(
2830
[0, '\u0301'], // COMBINING ACUTE ACCENT
2931
[1, 'a\u0301'], // á

0 commit comments

Comments
 (0)