Skip to content
Permalink
Browse files

lib: restore `global.module` after --eval code is run

PR-URL: #27587
Fixes: #27575
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information...
addaleax committed May 6, 2019
1 parent f2a48c8 commit b2308339127488b12d79f4775f83e2afca459945
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/internal/process/execution.js
@@ -55,6 +55,7 @@ function evalScript(name, body, breakFirstLine, printResult) {
const { kVmBreakFirstLineSymbol } = require('internal/util');

const cwd = tryGetCwd();
const origModule = global.module; // Set e.g. when called from the REPL.

const module = new CJSModule(name);
module.filename = path.join(cwd, name);
@@ -79,6 +80,9 @@ function evalScript(name, body, breakFirstLine, printResult) {
const { kStdout, print } = require('internal/util/print');
print(kStdout, result);
}

if (origModule !== undefined)
global.module = origModule;
}

const exceptionHandlerState = { captureFn: null };

0 comments on commit b230833

Please sign in to comment.
You can’t perform that action at this time.