src,lib: make process.binding('config') internal
PR-URL: https://github.com/nodejs/node/pull/23400 Refs: https://github.com/nodejs/node/issues/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>
This commit is contained in:
parent
89740a4f0e
commit
63b06551f4
@ -50,7 +50,7 @@ const {
|
|||||||
} = require('internal/util/types');
|
} = require('internal/util/types');
|
||||||
const {
|
const {
|
||||||
pendingDeprecation
|
pendingDeprecation
|
||||||
} = process.binding('config');
|
} = internalBinding('config');
|
||||||
const {
|
const {
|
||||||
ERR_BUFFER_OUT_OF_BOUNDS,
|
ERR_BUFFER_OUT_OF_BOUNDS,
|
||||||
ERR_OUT_OF_RANGE,
|
ERR_OUT_OF_RANGE,
|
||||||
@ -1067,7 +1067,7 @@ Buffer.prototype.swap64 = function swap64() {
|
|||||||
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
||||||
|
|
||||||
let transcode;
|
let transcode;
|
||||||
if (process.binding('config').hasIntl) {
|
if (internalBinding('config').hasIntl) {
|
||||||
const {
|
const {
|
||||||
icuErrName,
|
icuErrName,
|
||||||
transcode: _transcode
|
transcode: _transcode
|
||||||
|
@ -40,7 +40,7 @@ const pendingDeprecation = getOptionValue('--pending-deprecation');
|
|||||||
const {
|
const {
|
||||||
fipsMode,
|
fipsMode,
|
||||||
fipsForced
|
fipsForced
|
||||||
} = process.binding('config');
|
} = internalBinding('config');
|
||||||
const { getFipsCrypto, setFipsCrypto } = internalBinding('crypto');
|
const { getFipsCrypto, setFipsCrypto } = internalBinding('crypto');
|
||||||
const {
|
const {
|
||||||
randomBytes,
|
randomBytes,
|
||||||
|
@ -107,7 +107,7 @@ function fatalError(e) {
|
|||||||
Error.captureStackTrace(o, fatalError);
|
Error.captureStackTrace(o, fatalError);
|
||||||
process._rawDebug(o.stack);
|
process._rawDebug(o.stack);
|
||||||
}
|
}
|
||||||
if (process.binding('config').shouldAbortOnUncaughtException) {
|
if (internalBinding('config').shouldAbortOnUncaughtException) {
|
||||||
process.abort();
|
process.abort();
|
||||||
}
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -73,6 +73,7 @@ ObjectDefineProperty(process, 'moduleLoadList', {
|
|||||||
writable: false
|
writable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// internalBindingWhitelist contains the name of internalBinding modules
|
// internalBindingWhitelist contains the name of internalBinding modules
|
||||||
// that are whitelisted for access via process.binding()... This is used
|
// that are whitelisted for access via process.binding()... This is used
|
||||||
// to provide a transition path for modules that are being moved over to
|
// to provide a transition path for modules that are being moved over to
|
||||||
@ -81,6 +82,7 @@ const internalBindingWhitelist = [
|
|||||||
'async_wrap',
|
'async_wrap',
|
||||||
'buffer',
|
'buffer',
|
||||||
'cares_wrap',
|
'cares_wrap',
|
||||||
|
'config',
|
||||||
'constants',
|
'constants',
|
||||||
'contextify',
|
'contextify',
|
||||||
'crypto',
|
'crypto',
|
||||||
@ -168,7 +170,7 @@ function NativeModule(id) {
|
|||||||
NativeModule._source = getInternalBinding('natives');
|
NativeModule._source = getInternalBinding('natives');
|
||||||
NativeModule._cache = {};
|
NativeModule._cache = {};
|
||||||
|
|
||||||
const config = getBinding('config');
|
const config = getInternalBinding('config');
|
||||||
|
|
||||||
// Think of this as module.exports in this file even though it is not
|
// Think of this as module.exports in this file even though it is not
|
||||||
// written in CommonJS style.
|
// written in CommonJS style.
|
||||||
|
@ -176,7 +176,7 @@ function startup() {
|
|||||||
{
|
{
|
||||||
// Install legacy getters on the `util` binding for typechecking.
|
// Install legacy getters on the `util` binding for typechecking.
|
||||||
// TODO(addaleax): Turn into a full runtime deprecation.
|
// TODO(addaleax): Turn into a full runtime deprecation.
|
||||||
const { pendingDeprecation } = process.binding('config');
|
const { pendingDeprecation } = internalBinding('config');
|
||||||
const utilBinding = internalBinding('util');
|
const utilBinding = internalBinding('util');
|
||||||
const types = internalBinding('types');
|
const types = internalBinding('types');
|
||||||
for (const name of [
|
for (const name of [
|
||||||
@ -638,7 +638,7 @@ function setupProcessFatal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupProcessICUVersions() {
|
function setupProcessICUVersions() {
|
||||||
const icu = process.binding('config').hasIntl ?
|
const icu = internalBinding('config').hasIntl ?
|
||||||
internalBinding('icu') : undefined;
|
internalBinding('icu') : undefined;
|
||||||
if (!icu) return; // no Intl/ICU: nothing to add here.
|
if (!icu) return; // no Intl/ICU: nothing to add here.
|
||||||
// With no argument, getVersion() returns a comma separated list
|
// With no argument, getVersion() returns a comma separated list
|
||||||
|
@ -342,7 +342,7 @@ Object.defineProperties(
|
|||||||
} });
|
} });
|
||||||
|
|
||||||
const TextDecoder =
|
const TextDecoder =
|
||||||
process.binding('config').hasIntl ?
|
internalBinding('config').hasIntl ?
|
||||||
makeTextDecoderICU() :
|
makeTextDecoderICU() :
|
||||||
makeTextDecoderJS();
|
makeTextDecoderJS();
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ let config;
|
|||||||
|
|
||||||
function lazyHookCreation() {
|
function lazyHookCreation() {
|
||||||
const { createHook } = require('async_hooks');
|
const { createHook } = require('async_hooks');
|
||||||
config = process.binding('config');
|
config = internalBinding('config');
|
||||||
|
|
||||||
hook = createHook({
|
hook = createHook({
|
||||||
init(asyncId, type, triggerAsyncId, resource) {
|
init(asyncId, type, triggerAsyncId, resource) {
|
||||||
|
@ -9,7 +9,7 @@ for (const key of Object.keys(types))
|
|||||||
|
|
||||||
// Environment variables are parsed ad-hoc throughout the code base,
|
// Environment variables are parsed ad-hoc throughout the code base,
|
||||||
// so we gather the documentation here.
|
// so we gather the documentation here.
|
||||||
const { hasIntl, hasSmallICU, hasNodeOptions } = process.binding('config');
|
const { hasIntl, hasSmallICU, hasNodeOptions } = internalBinding('config');
|
||||||
const envVars = new Map([
|
const envVars = new Map([
|
||||||
['NODE_DEBUG', { helpText: "','-separated list of core modules that " +
|
['NODE_DEBUG', { helpText: "','-separated list of core modules that " +
|
||||||
'should print debug information' }],
|
'should print debug information' }],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const config = process.binding('config');
|
const config = internalBinding('config');
|
||||||
const prefix = `(${process.release.name}:${process.pid}) `;
|
const prefix = `(${process.release.name}:${process.pid}) `;
|
||||||
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
|
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ CSI.kClearToEnd = CSI`0K`;
|
|||||||
CSI.kClearLine = CSI`2K`;
|
CSI.kClearLine = CSI`2K`;
|
||||||
CSI.kClearScreenDown = CSI`0J`;
|
CSI.kClearScreenDown = CSI`0J`;
|
||||||
|
|
||||||
if (process.binding('config').hasIntl) {
|
if (internalBinding('config').hasIntl) {
|
||||||
const icu = internalBinding('icu');
|
const icu = internalBinding('icu');
|
||||||
getStringWidth = function getStringWidth(str, options) {
|
getStringWidth = function getStringWidth(str, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { hasTracing } = process.binding('config');
|
const { hasTracing } = internalBinding('config');
|
||||||
const kHandle = Symbol('handle');
|
const kHandle = Symbol('handle');
|
||||||
const kEnabled = Symbol('enabled');
|
const kEnabled = Symbol('enabled');
|
||||||
const kCategories = Symbol('categories');
|
const kCategories = Symbol('categories');
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { toASCII } = process.binding('config').hasIntl ?
|
const { toASCII } = internalBinding('config').hasIntl ?
|
||||||
internalBinding('icu') : require('punycode');
|
internalBinding('icu') : require('punycode');
|
||||||
|
|
||||||
const { hexTable } = require('internal/querystring');
|
const { hexTable } = require('internal/querystring');
|
||||||
|
@ -112,4 +112,4 @@ static void Initialize(Local<Object> target,
|
|||||||
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(config, node::Initialize)
|
NODE_MODULE_CONTEXT_AWARE_INTERNAL(config, node::Initialize)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const { internalBinding } = require('internal/test/binding');
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
const { hasSmallICU } = process.binding('config');
|
const { hasSmallICU } = internalBinding('config');
|
||||||
if (!(common.hasIntl && hasSmallICU))
|
if (!(common.hasIntl && hasSmallICU))
|
||||||
common.skip('missing Intl');
|
common.skip('missing Intl');
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const config = process.binding('config');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const config = internalBinding('config');
|
||||||
|
|
||||||
console.log(config, process.argv);
|
console.log(config, process.argv);
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const { internalBinding } = require('internal/test/binding');
|
||||||
require('../common');
|
require('../common');
|
||||||
const { PassThrough } = require('stream');
|
const { PassThrough } = require('stream');
|
||||||
const readline = require('readline');
|
const readline = require('readline');
|
||||||
@ -23,7 +25,7 @@ const ctrlU = { ctrl: true, name: 'u' };
|
|||||||
// The non-ICU JS implementation of character width calculation is only aware
|
// The non-ICU JS implementation of character width calculation is only aware
|
||||||
// of the wide/narrow distinction. Only test these more advanced cases when
|
// of the wide/narrow distinction. Only test these more advanced cases when
|
||||||
// ICU is available.
|
// ICU is available.
|
||||||
if (process.binding('config').hasIntl) {
|
if (internalBinding('config').hasIntl) {
|
||||||
tests.push(
|
tests.push(
|
||||||
[0, '\u0301'], // COMBINING ACUTE ACCENT
|
[0, '\u0301'], // COMBINING ACUTE ACCENT
|
||||||
[1, 'a\u0301'], // á
|
[1, 'a\u0301'], // á
|
||||||
|
Loading…
x
Reference in New Issue
Block a user