Skip to content

Commit

Permalink
lib: add process to internal module wrapper
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
addaleax authored and MylesBorins committed Feb 26, 2018
1 parent 743cf33 commit 738b0a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@
};

NativeModule.wrapper = [
'(function (exports, require, module, internalBinding) {',
'(function (exports, require, module, internalBinding, process) {',
'\n});'
];

Expand All @@ -650,7 +650,7 @@
lineOffset: 0,
displayErrors: true
});
fn(this.exports, NativeModule.require, this, internalBinding);
fn(this.exports, NativeModule.require, this, internalBinding, process);

this.loaded = true;
} finally {
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-repl-let-process.js
Original file line number Diff line number Diff line change
@@ -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']);

0 comments on commit 738b0a1

Please sign in to comment.