Skip to content

Commit 738b0a1

Browse files
addaleaxMylesBorins
authored andcommitted
lib: add process to internal module wrapper
Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. Backport-PR-URL: #19006 PR-URL: #17198 Fixes: #6802 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 743cf33 commit 738b0a1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/internal/bootstrap_node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
};
635635

636636
NativeModule.wrapper = [
637-
'(function (exports, require, module, internalBinding) {',
637+
'(function (exports, require, module, internalBinding, process) {',
638638
'\n});'
639639
];
640640

@@ -650,7 +650,7 @@
650650
lineOffset: 0,
651651
displayErrors: true
652652
});
653-
fn(this.exports, NativeModule.require, this, internalBinding);
653+
fn(this.exports, NativeModule.require, this, internalBinding, process);
654654

655655
this.loaded = true;
656656
} finally {
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
const common = require('../common');
3+
const repl = require('repl');
4+
5+
common.globalCheck = false;
6+
7+
// Regression test for https://github.com/nodejs/node/issues/6802
8+
const input = new common.ArrayStream();
9+
repl.start({ input, output: process.stdout, useGlobal: true });
10+
input.run(['let process']);

0 commit comments

Comments
 (0)