From ab93dab8f7418577a1028e441a32bd842558ce53 Mon Sep 17 00:00:00 2001 From: voltrexmaster Date: Sat, 30 Oct 2021 02:28:26 -0700 Subject: [PATCH] process: refactor execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Removed unreachable code of the `evalModule()` function as an early error is thrown when the `print` parameter is a truthy value. • Make use of the nullish coalescing operator. --- lib/internal/process/execution.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 48c525057f7477..e10a4f413cdd0d 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -42,15 +42,9 @@ function evalModule(source, print) { if (print) { throw new ERR_EVAL_ESM_CANNOT_PRINT(); } - const { log } = require('internal/console/global'); const { loadESM } = require('internal/process/esm_loader'); const { handleMainPromise } = require('internal/modules/run_main'); - return handleMainPromise(loadESM(async (loader) => { - const { result } = await loader.eval(source); - if (print) { - log(result); - } - })); + return handleMainPromise(loadESM((loader) => loader.eval(source))); } function evalScript(name, body, breakFirstLine, print) { @@ -158,7 +152,7 @@ function createOnGlobalUncaughtException() { 'Exception', 'Exception', null, - er ? er : {}); + er ?? {}); } } catch {} // Ignore the exception. Diagnostic reporting is unavailable. }