Skip to content

Commit

Permalink
lib: restore global.module after --eval code is run
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed May 6, 2019
1 parent e5397a6 commit 9ee9176
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/internal/process/execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 };
Expand Down

0 comments on commit 9ee9176

Please sign in to comment.