diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-01-27 01:18:47 +0100 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-02-06 07:30:39 +0100 |
commit | f9fe037088d66b2ad4bab5bd299be1e78065d776 (patch) | |
tree | d2486c4813e0dcb2397e1b3bd9f4930fd3893571 /lib | |
parent | e3055dc5254502d2f02276f20c9a3f37b41e7f12 (diff) | |
download | android-node-v8-f9fe037088d66b2ad4bab5bd299be1e78065d776.tar.gz android-node-v8-f9fe037088d66b2ad4bab5bd299be1e78065d776.tar.bz2 android-node-v8-f9fe037088d66b2ad4bab5bd299be1e78065d776.zip |
repl: fix eval return value
In case no error has occurred during the evaluation of some code,
`undefined` has been returned in some cases as error argument instead
of `null`. This is fixed by this patch.
PR-URL: https://github.com/nodejs/node/pull/25731
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/repl.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/repl.js b/lib/repl.js index df861843d1..e0f5373c8c 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -215,10 +215,11 @@ function REPLServer(prompt, } function defaultEval(code, context, file, cb) { - var err, result, script, wrappedErr; - var wrappedCmd = false; - var awaitPromise = false; - var input = code; + let result, script, wrappedErr; + let err = null; + let wrappedCmd = false; + let awaitPromise = false; + const input = code; if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) { // It's confusing for `{ a : 1 }` to be interpreted as a block @@ -362,7 +363,7 @@ function REPLServer(prompt, } promise.then((result) => { - finishExecution(undefined, result); + finishExecution(null, result); }, (err) => { if (err && process.domain) { debug('not recoverable, send to domain'); |