From e8a26e783e2e33514d44d8b2725d5f048e1314ce Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 21 Nov 2017 19:24:09 +0100 Subject: [PATCH] lib: add `process` to internal module wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: James M Snell Reviewed-By: Lance Ball Reviewed-By: Anatoli Papirovski Reviewed-By: Joyee Cheung Reviewed-By: Alexey Orlenko Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Timothy Gu Reviewed-By: Refael Ackermann --- lib/internal/bootstrap_node.js | 4 ++-- test/parallel/test-repl-let-process.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-repl-let-process.js diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index a565916193000f..d8ebd9af968cf2 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -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 { diff --git a/test/parallel/test-repl-let-process.js b/test/parallel/test-repl-let-process.js new file mode 100644 index 00000000000000..3e6c3e85665be1 --- /dev/null +++ b/test/parallel/test-repl-let-process.js @@ -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']);