Skip to content

Commit ea968d5

Browse files
VoltrexKeyvatargos
authored andcommitted
process: refactor execution
• 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. PR-URL: #40664 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent 306d953 commit ea968d5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/internal/process/execution.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,9 @@ function evalModule(source, print) {
4242
if (print) {
4343
throw new ERR_EVAL_ESM_CANNOT_PRINT();
4444
}
45-
const { log } = require('internal/console/global');
4645
const { loadESM } = require('internal/process/esm_loader');
4746
const { handleMainPromise } = require('internal/modules/run_main');
48-
return handleMainPromise(loadESM(async (loader) => {
49-
const { result } = await loader.eval(source);
50-
if (print) {
51-
log(result);
52-
}
53-
}));
47+
return handleMainPromise(loadESM((loader) => loader.eval(source)));
5448
}
5549

5650
function evalScript(name, body, breakFirstLine, print) {
@@ -158,7 +152,7 @@ function createOnGlobalUncaughtException() {
158152
'Exception',
159153
'Exception',
160154
null,
161-
er ? er : {});
155+
er ?? {});
162156
}
163157
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
164158
}

0 commit comments

Comments
 (0)