@@ -402,47 +402,44 @@ MaybeLocal<Value> StartMainThreadExecution(Environment* env) {
402402 return StartExecution (env, " internal/main/run_third_party_main" );
403403 }
404404
405- if (env->execution_mode () == Environment::ExecutionMode::kInspect ||
406- env->execution_mode () == Environment::ExecutionMode::kDebug ) {
405+ std::string first_argv;
406+ if (env->argv ().size () > 1 ) {
407+ first_argv = env->argv ()[1 ];
408+ }
409+
410+ if (first_argv == " inspect" || first_argv == " debug" ) {
407411 return StartExecution (env, " internal/main/inspect" );
408412 }
409413
410414 if (per_process::cli_options->print_help ) {
411- env->set_execution_mode (Environment::ExecutionMode::kPrintHelp );
412415 return StartExecution (env, " internal/main/print_help" );
413416 }
414417
415418 if (per_process::cli_options->print_bash_completion ) {
416- env->set_execution_mode (Environment::ExecutionMode::kPrintBashCompletion );
417419 return StartExecution (env, " internal/main/print_bash_completion" );
418420 }
419421
420422 if (env->options ()->prof_process ) {
421- env->set_execution_mode (Environment::ExecutionMode::kProfProcess );
422423 return StartExecution (env, " internal/main/prof_process" );
423424 }
424425
425426 // -e/--eval without -i/--interactive
426427 if (env->options ()->has_eval_string && !env->options ()->force_repl ) {
427- env->set_execution_mode (Environment::ExecutionMode::kEvalString );
428428 return StartExecution (env, " internal/main/eval_string" );
429429 }
430430
431431 if (env->options ()->syntax_check_only ) {
432- env->set_execution_mode (Environment::ExecutionMode::kCheckSyntax );
433432 return StartExecution (env, " internal/main/check_syntax" );
434433 }
435434
436- if (env-> execution_mode () == Environment::ExecutionMode:: kRunMainModule ) {
435+ if (!first_argv. empty () && first_argv != " - " ) {
437436 return StartExecution (env, " internal/main/run_main_module" );
438437 }
439438
440439 if (env->options ()->force_repl || uv_guess_handle (STDIN_FILENO) == UV_TTY) {
441- env->set_execution_mode (Environment::ExecutionMode::kRepl );
442440 return StartExecution (env, " internal/main/repl" );
443441 }
444442
445- env->set_execution_mode (Environment::ExecutionMode::kEvalStdin );
446443 return StartExecution (env, " internal/main/eval_stdin" );
447444}
448445
0 commit comments