mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 22:42:51 +00:00

PR-URL: https://github.com/nodejs/node/pull/49869 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
39 lines
1023 B
JavaScript
39 lines
1023 B
JavaScript
'use strict';
|
|
|
|
// Stdin is not a TTY, we will read it and execute it.
|
|
|
|
const {
|
|
prepareMainThreadExecution,
|
|
markBootstrapComplete,
|
|
} = require('internal/process/pre_execution');
|
|
|
|
const { getOptionValue } = require('internal/options');
|
|
|
|
const {
|
|
evalModule,
|
|
evalScript,
|
|
readStdin,
|
|
} = require('internal/process/execution');
|
|
|
|
prepareMainThreadExecution();
|
|
markBootstrapComplete();
|
|
|
|
readStdin((code) => {
|
|
// This is necessary for fork() and CJS module compilation.
|
|
// TODO(joyeecheung): pass this with something really internal.
|
|
process._eval = code;
|
|
|
|
const print = getOptionValue('--print');
|
|
const loadESM = getOptionValue('--import').length > 0;
|
|
if (getOptionValue('--input-type') === 'module' ||
|
|
(getOptionValue('--experimental-default-type') === 'module' && getOptionValue('--input-type') !== 'commonjs')) {
|
|
evalModule(code, print);
|
|
} else {
|
|
evalScript('[stdin]',
|
|
code,
|
|
getOptionValue('--inspect-brk'),
|
|
print,
|
|
loadESM);
|
|
}
|
|
});
|