Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-05-06 22:54:32 +0300
committerAnna Henningsen <anna@addaleax.net>2019-05-12 16:04:27 +0300
commitf2a48c8245e93939987d2df1bfd5e9c42899b045 (patch)
treee7cdce782d97bdc76afba5f9ea95afd10f60b896 /lib/internal/main
parent1d31c6833df85cd913c241cdc4b4d702490fee7b (diff)
repl: do not run --eval code if there is none
`getOptionValue('--eval')` always returns a string, so it is never loose-equal to `null`. Running eval makes some modifications to the global object, including setting `module` to a different value, which we want to avoid if possible. Refs: https://github.com/nodejs/node/pull/27278 PR-URL: https://github.com/nodejs/node/pull/27587 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/internal/main')
-rw-r--r--lib/internal/main/repl.js5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/internal/main/repl.js b/lib/internal/main/repl.js
index 58afb2be987..b38102a1548 100644
--- a/lib/internal/main/repl.js
+++ b/lib/internal/main/repl.js
@@ -46,10 +46,9 @@ cliRepl.createInternalRepl(process.env, (err, repl) => {
// If user passed '-e' or '--eval' along with `-i` or `--interactive`,
// evaluate the code in the current context.
-const source = getOptionValue('--eval');
-if (source != null) {
+if (getOptionValue('[has_eval_string]')) {
evalScript('[eval]',
- source,
+ getOptionValue('--eval'),
getOptionValue('--inspect-brk'),
getOptionValue('--print'));
}