diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-05-07 00:44:08 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-05-12 15:04:38 +0200 |
commit | b2308339127488b12d79f4775f83e2afca459945 (patch) | |
tree | 632d5bf36973fac2f4870dfd76824288c7c2df13 /lib | |
parent | f2a48c8245e93939987d2df1bfd5e9c42899b045 (diff) | |
download | android-node-v8-b2308339127488b12d79f4775f83e2afca459945.tar.gz android-node-v8-b2308339127488b12d79f4775f83e2afca459945.tar.bz2 android-node-v8-b2308339127488b12d79f4775f83e2afca459945.zip |
lib: restore `global.module` after --eval code is run
PR-URL: https://github.com/nodejs/node/pull/27587
Fixes: https://github.com/nodejs/node/issues/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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/process/execution.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index c95567c506..5eda7541c8 100644 --- a/lib/internal/process/execution.js +++ b/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 }; |