Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: do not run --eval code if there is none #27587

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lib: restore global.module after --eval code is run
Refs: #27278
addaleax committed May 6, 2019

Verified

This commit was signed with the committer’s verified signature. The key has expired.
addaleax Anna Henningsen
commit 9ee91763e52ea702bb0d4997e32432e49782bc9a
4 changes: 4 additions & 0 deletions lib/internal/process/execution.js
Original file line number Diff line number Diff line change
@@ -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 };