@@ -402,47 +402,44 @@ MaybeLocal<Value> StartMainThreadExecution(Environment* env) {
402
402
return StartExecution (env, " internal/main/run_third_party_main" );
403
403
}
404
404
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" ) {
407
411
return StartExecution (env, " internal/main/inspect" );
408
412
}
409
413
410
414
if (per_process::cli_options->print_help ) {
411
- env->set_execution_mode (Environment::ExecutionMode::kPrintHelp );
412
415
return StartExecution (env, " internal/main/print_help" );
413
416
}
414
417
415
418
if (per_process::cli_options->print_bash_completion ) {
416
- env->set_execution_mode (Environment::ExecutionMode::kPrintBashCompletion );
417
419
return StartExecution (env, " internal/main/print_bash_completion" );
418
420
}
419
421
420
422
if (env->options ()->prof_process ) {
421
- env->set_execution_mode (Environment::ExecutionMode::kProfProcess );
422
423
return StartExecution (env, " internal/main/prof_process" );
423
424
}
424
425
425
426
// -e/--eval without -i/--interactive
426
427
if (env->options ()->has_eval_string && !env->options ()->force_repl ) {
427
- env->set_execution_mode (Environment::ExecutionMode::kEvalString );
428
428
return StartExecution (env, " internal/main/eval_string" );
429
429
}
430
430
431
431
if (env->options ()->syntax_check_only ) {
432
- env->set_execution_mode (Environment::ExecutionMode::kCheckSyntax );
433
432
return StartExecution (env, " internal/main/check_syntax" );
434
433
}
435
434
436
- if (env-> execution_mode () == Environment::ExecutionMode:: kRunMainModule ) {
435
+ if (!first_argv. empty () && first_argv != " - " ) {
437
436
return StartExecution (env, " internal/main/run_main_module" );
438
437
}
439
438
440
439
if (env->options ()->force_repl || uv_guess_handle (STDIN_FILENO) == UV_TTY) {
441
- env->set_execution_mode (Environment::ExecutionMode::kRepl );
442
440
return StartExecution (env, " internal/main/repl" );
443
441
}
444
442
445
- env->set_execution_mode (Environment::ExecutionMode::kEvalStdin );
446
443
return StartExecution (env, " internal/main/eval_stdin" );
447
444
}
448
445
0 commit comments