Skip to content

Commit

Permalink
process: refactor execution
Browse files Browse the repository at this point in the history
• 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.
  • Loading branch information
VoltrexKeyva committed Nov 3, 2021
1 parent 2e2a6fe commit ab93dab
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/internal/process/execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -158,7 +152,7 @@ function createOnGlobalUncaughtException() {
'Exception',
'Exception',
null,
er ? er : {});
er ?? {});
}
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
}
Expand Down

0 comments on commit ab93dab

Please sign in to comment.