Skip to content

Commit

Permalink
src,lib: make process.binding('config') internal
Browse files Browse the repository at this point in the history
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>

Backport-PR-URL: #25446
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
Masashi Hirano authored and addaleax committed Jan 14, 2019
1 parent 87a58be commit 7480864
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/buffer.js
Expand Up @@ -57,7 +57,7 @@ const {
} = require('internal/util/types');
const {
pendingDeprecation
} = process.binding('config');
} = internalBinding('config');
const {
formatProperty,
kObjectType
Expand Down Expand Up @@ -1083,7 +1083,7 @@ Buffer.prototype.swap64 = function swap64() {
Buffer.prototype.toLocaleString = Buffer.prototype.toString;

let transcode;
if (process.binding('config').hasIntl) {
if (internalBinding('config').hasIntl) {
const {
icuErrName,
transcode: _transcode
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.js
Expand Up @@ -40,7 +40,7 @@ const pendingDeprecation = getOptionValue('--pending-deprecation');
const {
fipsMode,
fipsForced
} = process.binding('config');
} = internalBinding('config');
const { getFipsCrypto, setFipsCrypto } = internalBinding('crypto');
const {
randomBytes,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/async_hooks.js
Expand Up @@ -107,7 +107,7 @@ function fatalError(e) {
Error.captureStackTrace(o, fatalError);
process._rawDebug(o.stack);
}
if (process.binding('config').shouldAbortOnUncaughtException) {
if (internalBinding('config').shouldAbortOnUncaughtException) {
process.abort();
}
process.exit(1);
Expand Down
4 changes: 3 additions & 1 deletion lib/internal/bootstrap/loaders.js
Expand Up @@ -73,6 +73,7 @@ ObjectDefineProperty(process, 'moduleLoadList', {
writable: false
});


// internalBindingWhitelist contains the name of internalBinding modules
// that are whitelisted for access via process.binding()... This is used
// to provide a transition path for modules that are being moved over to
Expand All @@ -81,6 +82,7 @@ const internalBindingWhitelist = [
'async_wrap',
'buffer',
'cares_wrap',
'config',
'constants',
'contextify',
'crypto',
Expand Down Expand Up @@ -168,7 +170,7 @@ function NativeModule(id) {
NativeModule._source = getInternalBinding('natives');
NativeModule._cache = {};

const config = getBinding('config');
const config = getInternalBinding('config');

// Think of this as module.exports in this file even though it is not
// written in CommonJS style.
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/bootstrap/node.js
Expand Up @@ -176,7 +176,7 @@ function startup() {
{
// Install legacy getters on the `util` binding for typechecking.
// TODO(addaleax): Turn into a full runtime deprecation.
const { pendingDeprecation } = process.binding('config');
const { pendingDeprecation } = internalBinding('config');
const utilBinding = internalBinding('util');
const types = internalBinding('types');
for (const name of [
Expand Down Expand Up @@ -638,7 +638,7 @@ function setupProcessFatal() {
}

function setupProcessICUVersions() {
const icu = process.binding('config').hasIntl ?
const icu = internalBinding('config').hasIntl ?
internalBinding('icu') : undefined;
if (!icu) return; // no Intl/ICU: nothing to add here.
// With no argument, getVersion() returns a comma separated list
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/encoding.js
Expand Up @@ -342,7 +342,7 @@ Object.defineProperties(
} });

const TextDecoder =
process.binding('config').hasIntl ?
internalBinding('config').hasIntl ?
makeTextDecoderICU() :
makeTextDecoderJS();

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/inspector_async_hook.js
Expand Up @@ -12,7 +12,7 @@ let config;

function lazyHookCreation() {
const { createHook } = require('async_hooks');
config = process.binding('config');
config = internalBinding('config');

hook = createHook({
init(asyncId, type, triggerAsyncId, resource) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/print_help.js
Expand Up @@ -9,7 +9,7 @@ for (const key of Object.keys(types))

// Environment variables are parsed ad-hoc throughout the code base,
// so we gather the documentation here.
const { hasIntl, hasSmallICU, hasNodeOptions } = process.binding('config');
const { hasIntl, hasSmallICU, hasNodeOptions } = internalBinding('config');
const envVars = new Map([
['NODE_DEBUG', { helpText: "','-separated list of core modules that " +
'should print debug information' }],
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/readline.js
Expand Up @@ -30,7 +30,7 @@ CSI.kClearToEnd = CSI`0K`;
CSI.kClearLine = CSI`2K`;
CSI.kClearScreenDown = CSI`0J`;

if (process.binding('config').hasIntl) {
if (internalBinding('config').hasIntl) {
const icu = internalBinding('icu');
getStringWidth = function getStringWidth(str, options) {
options = options || {};
Expand Down
2 changes: 1 addition & 1 deletion lib/trace_events.js
@@ -1,6 +1,6 @@
'use strict';

const { hasTracing } = process.binding('config');
const { hasTracing } = internalBinding('config');
const kHandle = Symbol('handle');
const kEnabled = Symbol('enabled');
const kCategories = Symbol('categories');
Expand Down
2 changes: 1 addition & 1 deletion lib/url.js
Expand Up @@ -21,7 +21,7 @@

'use strict';

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

const { hexTable } = require('internal/querystring');
Expand Down
2 changes: 1 addition & 1 deletion src/node_config.cc
Expand Up @@ -106,4 +106,4 @@ static void Initialize(Local<Object> target,

} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(config, node::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(config, node::Initialize)
4 changes: 3 additions & 1 deletion test/parallel/test-icu-data-dir.js
@@ -1,8 +1,10 @@
// Flags: --expose-internals
'use strict';
const { internalBinding } = require('internal/test/binding');
const common = require('../common');
const os = require('os');

const { hasSmallICU } = process.binding('config');
const { hasSmallICU } = internalBinding('config');
if (!(common.hasIntl && hasSmallICU))
common.skip('missing Intl');

Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-internal-modules-expose.js
Expand Up @@ -3,7 +3,8 @@

require('../common');
const assert = require('assert');
const config = process.binding('config');
const { internalBinding } = require('internal/test/binding');
const config = internalBinding('config');

console.log(config, process.argv);

Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-readline-position.js
@@ -1,4 +1,6 @@
// Flags: --expose-internals
'use strict';
const { internalBinding } = require('internal/test/binding');
require('../common');
const { PassThrough } = require('stream');
const readline = require('readline');
Expand All @@ -23,7 +25,7 @@ const ctrlU = { ctrl: true, name: 'u' };
// The non-ICU JS implementation of character width calculation is only aware
// of the wide/narrow distinction. Only test these more advanced cases when
// ICU is available.
if (process.binding('config').hasIntl) {
if (internalBinding('config').hasIntl) {
tests.push(
[0, '\u0301'], // COMBINING ACUTE ACCENT
[1, 'a\u0301'], // á
Expand Down

0 comments on commit 7480864

Please sign in to comment.