11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Stdin is not a TTY, we will read it and execute it. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst { 61cb0ef41Sopenharmony_ci prepareMainThreadExecution, 71cb0ef41Sopenharmony_ci markBootstrapComplete, 81cb0ef41Sopenharmony_ci} = require('internal/process/pre_execution'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst { getOptionValue } = require('internal/options'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst { 131cb0ef41Sopenharmony_ci evalModule, 141cb0ef41Sopenharmony_ci evalScript, 151cb0ef41Sopenharmony_ci readStdin, 161cb0ef41Sopenharmony_ci} = require('internal/process/execution'); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciprepareMainThreadExecution(); 191cb0ef41Sopenharmony_cimarkBootstrapComplete(); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cireadStdin((code) => { 221cb0ef41Sopenharmony_ci // This is necessary for fork() and CJS module compilation. 231cb0ef41Sopenharmony_ci // TODO(joyeecheung): pass this with something really internal. 241cb0ef41Sopenharmony_ci process._eval = code; 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci const print = getOptionValue('--print'); 271cb0ef41Sopenharmony_ci const loadESM = getOptionValue('--import').length > 0; 281cb0ef41Sopenharmony_ci if (getOptionValue('--input-type') === 'module' || 291cb0ef41Sopenharmony_ci (getOptionValue('--experimental-default-type') === 'module' && getOptionValue('--input-type') !== 'commonjs')) { 301cb0ef41Sopenharmony_ci evalModule(code, print); 311cb0ef41Sopenharmony_ci } else { 321cb0ef41Sopenharmony_ci evalScript('[stdin]', 331cb0ef41Sopenharmony_ci code, 341cb0ef41Sopenharmony_ci getOptionValue('--inspect-brk'), 351cb0ef41Sopenharmony_ci print, 361cb0ef41Sopenharmony_ci loadESM); 371cb0ef41Sopenharmony_ci } 381cb0ef41Sopenharmony_ci}); 39