From 738b0a1f2ef83b188909af80d3910c0a4d55055b 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`. Backport-PR-URL: https://github.com/nodejs/node/pull/19006 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 85d72f876124fa..b10b8fe54cf1ef 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -634,7 +634,7 @@ }; NativeModule.wrapper = [ - '(function (exports, require, module, internalBinding) {', + '(function (exports, require, module, internalBinding, process) {', '\n});' ]; @@ -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 { 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']);