From d197105476b7669207f761c64fbbd0dbed7cf916 Mon Sep 17 00:00:00 2001 From: briete Date: Mon, 17 Dec 2018 23:45:24 +0900 Subject: [PATCH] os: move process.binding('os') to internalBinding PR-URL: https://github.com/nodejs/node/pull/25087 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Backport-PR-URL: https://github.com/nodejs/node/pull/25446 --- lib/internal/bootstrap/loaders.js | 1 + lib/os.js | 2 +- src/node_os.cc | 2 +- test/parallel/test-os-checked-function.js | 6 +++++- .../test-process-binding-internalbinding-whitelist.js | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 90e19a75939090..cc3822995411f7 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -93,6 +93,7 @@ const internalBindingWhitelist = [ 'inspector', 'js_stream', 'natives', + 'os', 'pipe_wrap', 'process_wrap', 'signal_wrap', diff --git a/lib/os.js b/lib/os.js index 2c806908eeac98..1acc69a2415b3d 100644 --- a/lib/os.js +++ b/lib/os.js @@ -44,7 +44,7 @@ const { getUptime, isBigEndian, setPriority: _setPriority -} = process.binding('os'); +} = internalBinding('os'); function getCheckedFunction(fn) { return function checkError(...args) { diff --git a/src/node_os.cc b/src/node_os.cc index 72719f2933728c..6ecfb7fe9f8f44 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -467,4 +467,4 @@ void Initialize(Local target, } // namespace os } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(os, node::os::Initialize) +NODE_MODULE_CONTEXT_AWARE_INTERNAL(os, node::os::Initialize) diff --git a/test/parallel/test-os-checked-function.js b/test/parallel/test-os-checked-function.js index 04c2c3a1f82ea3..2a393f830d4b76 100644 --- a/test/parallel/test-os-checked-function.js +++ b/test/parallel/test-os-checked-function.js @@ -1,7 +1,11 @@ 'use strict'; +// Flags: --expose_internals + +const { internalBinding } = require('internal/test/binding'); + // Monkey patch the os binding before requiring any other modules, including // common, which requires the os module. -process.binding('os').getHomeDirectory = function(ctx) { +internalBinding('os').getHomeDirectory = function(ctx) { ctx.syscall = 'foo'; ctx.code = 'bar'; ctx.message = 'baz'; diff --git a/test/parallel/test-process-binding-internalbinding-whitelist.js b/test/parallel/test-process-binding-internalbinding-whitelist.js index dafac9476922ab..044757e98dc402 100644 --- a/test/parallel/test-process-binding-internalbinding-whitelist.js +++ b/test/parallel/test-process-binding-internalbinding-whitelist.js @@ -18,3 +18,4 @@ assert(process.binding('js_stream')); assert(process.binding('buffer')); assert(process.binding('fs')); assert(process.binding('inspector')); +assert(process.binding('os'));