From 577da835d298dd32aea366f299f1cb92103fe489 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 11 Jan 2019 22:33:29 +0800 Subject: [PATCH] Revert "src,lib: make process.binding('config') internal" This reverts commit 88a54497e558dc4677d2c5102d24f0fd026267eb. PR-URL: https://github.com/nodejs/node/pull/25446 Reviewed-By: Anna Henningsen --- lib/buffer.js | 4 ++-- lib/crypto.js | 2 +- lib/internal/async_hooks.js | 2 +- lib/internal/bootstrap/loaders.js | 3 +-- lib/internal/bootstrap/node.js | 4 ++-- lib/internal/encoding.js | 2 +- lib/internal/inspector_async_hook.js | 2 +- lib/internal/print_help.js | 2 +- lib/internal/readline.js | 2 +- lib/trace_events.js | 2 +- lib/url.js | 2 +- src/node_config.cc | 2 +- test/parallel/test-icu-data-dir.js | 4 +--- test/parallel/test-internal-modules-expose.js | 3 +-- test/parallel/test-readline-position.js | 4 +--- 15 files changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index dc7f5c7cdb829b..cc64a8000f7e14 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -57,7 +57,7 @@ const { } = require('internal/util/types'); const { pendingDeprecation -} = internalBinding('config'); +} = process.binding('config'); const { formatProperty, kObjectType @@ -1083,7 +1083,7 @@ Buffer.prototype.swap64 = function swap64() { Buffer.prototype.toLocaleString = Buffer.prototype.toString; let transcode; -if (internalBinding('config').hasIntl) { +if (process.binding('config').hasIntl) { const { icuErrName, transcode: _transcode diff --git a/lib/crypto.js b/lib/crypto.js index 5b83a669c643d7..bb8436bffad3ae 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -40,7 +40,7 @@ const pendingDeprecation = getOptionValue('--pending-deprecation'); const { fipsMode, fipsForced -} = internalBinding('config'); +} = process.binding('config'); const { getFipsCrypto, setFipsCrypto } = internalBinding('crypto'); const { randomBytes, diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index d382fe36e1847f..a42f603293c82e 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -107,7 +107,7 @@ function fatalError(e) { Error.captureStackTrace(o, fatalError); process._rawDebug(o.stack); } - if (internalBinding('config').shouldAbortOnUncaughtException) { + if (process.binding('config').shouldAbortOnUncaughtException) { process.abort(); } process.exit(1); diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 48d83f12e12186..02abc683072ae2 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -79,7 +79,6 @@ 'buffer', 'cares_wrap', 'constants', - 'config', 'contextify', 'crypto', 'fs_event_wrap', @@ -165,7 +164,7 @@ NativeModule._source = getInternalBinding('natives'); NativeModule._cache = {}; - const config = getInternalBinding('config'); + const config = getBinding('config'); // Think of this as module.exports in this file even though it is not // written in CommonJS style. diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 3abbf8436f4e18..9f93d191d8e3e3 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -175,7 +175,7 @@ { // Install legacy getters on the `util` binding for typechecking. // TODO(addaleax): Turn into a full runtime deprecation. - const { pendingDeprecation } = internalBinding('config'); + const { pendingDeprecation } = process.binding('config'); const utilBinding = internalBinding('util'); const types = internalBinding('types'); for (const name of [ @@ -637,7 +637,7 @@ } function setupProcessICUVersions() { - const icu = internalBinding('config').hasIntl ? + const icu = process.binding('config').hasIntl ? internalBinding('icu') : undefined; if (!icu) return; // no Intl/ICU: nothing to add here. // With no argument, getVersion() returns a comma separated list diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index ad056fd0bd997f..ce3cc7411a65b8 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -342,7 +342,7 @@ Object.defineProperties( } }); const TextDecoder = - internalBinding('config').hasIntl ? + process.binding('config').hasIntl ? makeTextDecoderICU() : makeTextDecoderJS(); diff --git a/lib/internal/inspector_async_hook.js b/lib/internal/inspector_async_hook.js index 1ad0cbf3a533f2..6a7489af974a40 100644 --- a/lib/internal/inspector_async_hook.js +++ b/lib/internal/inspector_async_hook.js @@ -12,7 +12,7 @@ let config; function lazyHookCreation() { const { createHook } = require('async_hooks'); - config = internalBinding('config'); + config = process.binding('config'); hook = createHook({ init(asyncId, type, triggerAsyncId, resource) { diff --git a/lib/internal/print_help.js b/lib/internal/print_help.js index fdec7bd09bd87e..6e904a6b18633d 100644 --- a/lib/internal/print_help.js +++ b/lib/internal/print_help.js @@ -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 } = internalBinding('config'); +const { hasIntl, hasSmallICU, hasNodeOptions } = process.binding('config'); const envVars = new Map([ ['NODE_DEBUG', { helpText: "','-separated list of core modules that " + 'should print debug information' }], diff --git a/lib/internal/readline.js b/lib/internal/readline.js index f1716f1f25824f..639b5938da2223 100644 --- a/lib/internal/readline.js +++ b/lib/internal/readline.js @@ -30,7 +30,7 @@ CSI.kClearToEnd = CSI`0K`; CSI.kClearLine = CSI`2K`; CSI.kClearScreenDown = CSI`0J`; -if (internalBinding('config').hasIntl) { +if (process.binding('config').hasIntl) { const icu = internalBinding('icu'); getStringWidth = function getStringWidth(str, options) { options = options || {}; diff --git a/lib/trace_events.js b/lib/trace_events.js index d2977679e168b8..878580c67f5a2f 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -1,6 +1,6 @@ 'use strict'; -const { hasTracing } = internalBinding('config'); +const { hasTracing } = process.binding('config'); const kHandle = Symbol('handle'); const kEnabled = Symbol('enabled'); const kCategories = Symbol('categories'); diff --git a/lib/url.js b/lib/url.js index 9755cf430af924..d68e15f85b0d8e 100644 --- a/lib/url.js +++ b/lib/url.js @@ -21,7 +21,7 @@ 'use strict'; -const { toASCII } = internalBinding('config').hasIntl ? +const { toASCII } = process.binding('config').hasIntl ? internalBinding('icu') : require('punycode'); const { hexTable } = require('internal/querystring'); diff --git a/src/node_config.cc b/src/node_config.cc index a8ffac2cc158a4..c2a89bee2951a7 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -106,4 +106,4 @@ static void Initialize(Local target, } // namespace node -NODE_MODULE_CONTEXT_AWARE_INTERNAL(config, node::Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(config, node::Initialize) diff --git a/test/parallel/test-icu-data-dir.js b/test/parallel/test-icu-data-dir.js index daf15ba880ced7..47c955bc740fb3 100644 --- a/test/parallel/test-icu-data-dir.js +++ b/test/parallel/test-icu-data-dir.js @@ -1,10 +1,8 @@ -// Flags: --expose-internals 'use strict'; -const { internalBinding } = require('internal/test/binding'); const common = require('../common'); const os = require('os'); -const { hasSmallICU } = internalBinding('config'); +const { hasSmallICU } = process.binding('config'); if (!(common.hasIntl && hasSmallICU)) common.skip('missing Intl'); diff --git a/test/parallel/test-internal-modules-expose.js b/test/parallel/test-internal-modules-expose.js index 5229032573088e..ab48e36881268c 100644 --- a/test/parallel/test-internal-modules-expose.js +++ b/test/parallel/test-internal-modules-expose.js @@ -3,8 +3,7 @@ require('../common'); const assert = require('assert'); -const { internalBinding } = require('internal/test/binding'); -const config = internalBinding('config'); +const config = process.binding('config'); console.log(config, process.argv); diff --git a/test/parallel/test-readline-position.js b/test/parallel/test-readline-position.js index 0e62761ca57b40..4e1114418eb380 100644 --- a/test/parallel/test-readline-position.js +++ b/test/parallel/test-readline-position.js @@ -1,6 +1,4 @@ -// Flags: --expose-internals 'use strict'; -const { internalBinding } = require('internal/test/binding'); require('../common'); const { PassThrough } = require('stream'); const readline = require('readline'); @@ -25,7 +23,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 (internalBinding('config').hasIntl) { + if (process.binding('config').hasIntl) { tests.push( [0, '\u0301'], // COMBINING ACUTE ACCENT [1, 'a\u0301'], // á