lib: add process to internal module wrapper

Share `process` through the module wrapper rather than relying
on nobody messing with `global.process`.

PR-URL: https://github.com/nodejs/node/pull/17198
Fixes: https://github.com/nodejs/node/issues/6802
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
Anna Henningsen 2017-11-21 19:24:09 +01:00
parent 0319a5e180
commit e8a26e783e
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
2 changed files with 12 additions and 2 deletions

View File

@ -608,7 +608,7 @@
};
NativeModule.wrapper = [
'(function (exports, require, module, internalBinding) {',
'(function (exports, require, module, internalBinding, process) {',
'\n});'
];
@ -627,7 +627,7 @@
const requireFn = this.id.startsWith('internal/deps/') ?
NativeModule.requireForDeps :
NativeModule.require;
fn(this.exports, requireFn, this, internalBinding);
fn(this.exports, requireFn, this, internalBinding, process);
this.loaded = true;
} finally {

View File

@ -0,0 +1,10 @@
'use strict';
const common = require('../common');
const repl = require('repl');
common.globalCheck = false;
// Regression test for https://github.com/nodejs/node/issues/6802
const input = new common.ArrayStream();
repl.start({ input, output: process.stdout, useGlobal: true });
input.run(['let process']);