mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
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>
This commit is contained in:
parent
e3055dc525
commit
f9fe037088
11
lib/repl.js
11
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');
|
||||
|
Loading…
Reference in New Issue
Block a user