From 937c7695aa051ec84e682f5a39f868f3e18a08f5 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 --- 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 c33072560ad..af4928cc616 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 28e1d7797f6..602db10e927 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 77693a47ec9..5a40e171edb 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -470,4 +470,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 04c2c3a1f82..2a393f830d4 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 dafac947692..044757e98dc 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'));