From 5aaeb01655a9d0ada6b780de7b2e23205659967c Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 27 Jan 2019 01:18:47 +0100 Subject: [PATCH] repl: fix eval return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Ben Noordhuis --- lib/repl.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 4ba6141f59fa5d..ef1c6ee553bdea 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -216,10 +216,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 @@ -363,7 +364,7 @@ function REPLServer(prompt, } promise.then((result) => { - finishExecution(undefined, result); + finishExecution(null, result); }, (err) => { if (err && process.domain) { debug('not recoverable, send to domain');