Skip to content

Commit 5aaeb01

Browse files
BridgeARaddaleax
authored andcommitted
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: #25731 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent e66cb58 commit 5aaeb01

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/repl.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ function REPLServer(prompt,
216216
}
217217

218218
function defaultEval(code, context, file, cb) {
219-
var err, result, script, wrappedErr;
220-
var wrappedCmd = false;
221-
var awaitPromise = false;
222-
var input = code;
219+
let result, script, wrappedErr;
220+
let err = null;
221+
let wrappedCmd = false;
222+
let awaitPromise = false;
223+
const input = code;
223224

224225
if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) {
225226
// It's confusing for `{ a : 1 }` to be interpreted as a block
@@ -363,7 +364,7 @@ function REPLServer(prompt,
363364
}
364365

365366
promise.then((result) => {
366-
finishExecution(undefined, result);
367+
finishExecution(null, result);
367368
}, (err) => {
368369
if (err && process.domain) {
369370
debug('not recoverable, send to domain');

0 commit comments

Comments
 (0)