From a5511e45838b45f704d1388a4d8a0288feae2b4c 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 Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. Fixes: https://github.com/nodejs/node/issues/6802 --- 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 fb8bc762286467..bb7de659db4a4f 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -593,7 +593,7 @@ }; NativeModule.wrapper = [ - '(function (exports, require, module, internalBinding) {', + '(function (exports, require, module, internalBinding, process) {', '\n});' ]; @@ -612,7 +612,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']);