os: move process.binding('os') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/25087 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
13abc6adfb
commit
937c7695aa
@ -93,6 +93,7 @@ const internalBindingWhitelist = [
|
|||||||
'inspector',
|
'inspector',
|
||||||
'js_stream',
|
'js_stream',
|
||||||
'natives',
|
'natives',
|
||||||
|
'os',
|
||||||
'pipe_wrap',
|
'pipe_wrap',
|
||||||
'process_wrap',
|
'process_wrap',
|
||||||
'signal_wrap',
|
'signal_wrap',
|
||||||
|
@ -44,7 +44,7 @@ const {
|
|||||||
getUptime,
|
getUptime,
|
||||||
isBigEndian,
|
isBigEndian,
|
||||||
setPriority: _setPriority
|
setPriority: _setPriority
|
||||||
} = process.binding('os');
|
} = internalBinding('os');
|
||||||
|
|
||||||
function getCheckedFunction(fn) {
|
function getCheckedFunction(fn) {
|
||||||
return function checkError(...args) {
|
return function checkError(...args) {
|
||||||
|
@ -470,4 +470,4 @@ void Initialize(Local<Object> target,
|
|||||||
} // namespace os
|
} // namespace os
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(os, node::os::Initialize)
|
NODE_MODULE_CONTEXT_AWARE_INTERNAL(os, node::os::Initialize)
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose_internals
|
||||||
|
|
||||||
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
|
||||||
// Monkey patch the os binding before requiring any other modules, including
|
// Monkey patch the os binding before requiring any other modules, including
|
||||||
// common, which requires the os module.
|
// common, which requires the os module.
|
||||||
process.binding('os').getHomeDirectory = function(ctx) {
|
internalBinding('os').getHomeDirectory = function(ctx) {
|
||||||
ctx.syscall = 'foo';
|
ctx.syscall = 'foo';
|
||||||
ctx.code = 'bar';
|
ctx.code = 'bar';
|
||||||
ctx.message = 'baz';
|
ctx.message = 'baz';
|
||||||
|
@ -18,3 +18,4 @@ assert(process.binding('js_stream'));
|
|||||||
assert(process.binding('buffer'));
|
assert(process.binding('buffer'));
|
||||||
assert(process.binding('fs'));
|
assert(process.binding('fs'));
|
||||||
assert(process.binding('inspector'));
|
assert(process.binding('inspector'));
|
||||||
|
assert(process.binding('os'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user