From 55d185f0ddbbaf9d073ae9d89770de1d2207bfa2 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 2d197c768c7107..5c0a5b6aa1fb80 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -87,6 +87,7 @@ 'icu', '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 9cd12b54ea0f8a..c7b683a88a1376 100644 --- a/test/parallel/test-process-binding-internalbinding-whitelist.js +++ b/test/parallel/test-process-binding-internalbinding-whitelist.js @@ -16,3 +16,4 @@ assert(process.binding('url')); assert(process.binding('spawn_sync')); assert(process.binding('js_stream')); assert(process.binding('buffer')); +assert(process.binding('os'));