Skip to content

Commit 88b4d00

Browse files
addaleaxtargos
authored andcommitted
lib: restore global.module after --eval code is run
PR-URL: #27587 Fixes: #27575 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 688a0bd commit 88b4d00

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/internal/process/execution.js

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function evalScript(name, body, breakFirstLine, printResult) {
5555
const { kVmBreakFirstLineSymbol } = require('internal/util');
5656

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

5960
const module = new CJSModule(name);
6061
module.filename = path.join(cwd, name);
@@ -79,6 +80,9 @@ function evalScript(name, body, breakFirstLine, printResult) {
7980
const { kStdout, print } = require('internal/util/print');
8081
print(kStdout, result);
8182
}
83+
84+
if (origModule !== undefined)
85+
global.module = origModule;
8286
}
8387

8488
const exceptionHandlerState = { captureFn: null };

0 commit comments

Comments
 (0)