|
21 | 21 |
|
22 | 22 | #include "node.h" |
23 | 23 | #include "node_dotenv.h" |
| 24 | +#include "node_task_runner.h" |
24 | 25 |
|
25 | 26 | // ========== local headers ========== |
26 | 27 |
|
@@ -409,10 +410,6 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) { |
409 | 410 | return StartExecution(env, "internal/main/watch_mode"); |
410 | 411 | } |
411 | 412 |
|
412 | | - if (!env->options()->run.empty()) { |
413 | | - return StartExecution(env, "internal/main/run"); |
414 | | - } |
415 | | - |
416 | 413 | if (!first_argv.empty() && first_argv != "-") { |
417 | 414 | return StartExecution(env, "internal/main/run_main_module"); |
418 | 415 | } |
@@ -1025,11 +1022,11 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv, |
1025 | 1022 | InitializeNodeWithArgsInternal(argv, exec_argv, errors, flags)); |
1026 | 1023 | } |
1027 | 1024 |
|
1028 | | -static std::unique_ptr<InitializationResultImpl> |
| 1025 | +static std::shared_ptr<InitializationResultImpl> |
1029 | 1026 | InitializeOncePerProcessInternal(const std::vector<std::string>& args, |
1030 | 1027 | ProcessInitializationFlags::Flags flags = |
1031 | 1028 | ProcessInitializationFlags::kNoFlags) { |
1032 | | - auto result = std::make_unique<InitializationResultImpl>(); |
| 1029 | + auto result = std::make_shared<InitializationResultImpl>(); |
1033 | 1030 | result->args_ = args; |
1034 | 1031 |
|
1035 | 1032 | if (!(flags & ProcessInitializationFlags::kNoParseGlobalDebugVariables)) { |
@@ -1059,6 +1056,22 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args, |
1059 | 1056 | } |
1060 | 1057 | } |
1061 | 1058 |
|
| 1059 | + if (!per_process::cli_options->run.empty()) { |
| 1060 | + // TODO(@anonrig): Handle NODE_NO_WARNINGS, NODE_REDIRECT_WARNINGS, |
| 1061 | + // --disable-warning and --redirect-warnings. |
| 1062 | + if (per_process::cli_options->per_isolate->per_env->warnings) { |
| 1063 | + fprintf(stderr, |
| 1064 | + "ExperimentalWarning: Task runner is an experimental feature and " |
| 1065 | + "might change at any time\n\n"); |
| 1066 | + } |
| 1067 | + |
| 1068 | + auto positional_args = task_runner::GetPositionalArgs(args); |
| 1069 | + result->early_return_ = true; |
| 1070 | + task_runner::RunTask( |
| 1071 | + result, per_process::cli_options->run, positional_args); |
| 1072 | + return result; |
| 1073 | + } |
| 1074 | + |
1062 | 1075 | if (!(flags & ProcessInitializationFlags::kNoPrintHelpOrVersionOutput)) { |
1063 | 1076 | if (per_process::cli_options->print_version) { |
1064 | 1077 | printf("%s\n", NODE_VERSION); |
@@ -1218,7 +1231,7 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args, |
1218 | 1231 | return result; |
1219 | 1232 | } |
1220 | 1233 |
|
1221 | | -std::unique_ptr<InitializationResult> InitializeOncePerProcess( |
| 1234 | +std::shared_ptr<InitializationResult> InitializeOncePerProcess( |
1222 | 1235 | const std::vector<std::string>& args, |
1223 | 1236 | ProcessInitializationFlags::Flags flags) { |
1224 | 1237 | return InitializeOncePerProcessInternal(args, flags); |
@@ -1424,7 +1437,7 @@ static ExitCode StartInternal(int argc, char** argv) { |
1424 | 1437 | // Hack around with the argv pointer. Used for process.title = "blah". |
1425 | 1438 | argv = uv_setup_args(argc, argv); |
1426 | 1439 |
|
1427 | | - std::unique_ptr<InitializationResultImpl> result = |
| 1440 | + std::shared_ptr<InitializationResultImpl> result = |
1428 | 1441 | InitializeOncePerProcessInternal( |
1429 | 1442 | std::vector<std::string>(argv, argv + argc)); |
1430 | 1443 | for (const std::string& error : result->errors()) { |
|
0 commit comments