|
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 |
|
@@ -360,10 +361,6 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) { |
360 | 361 | return StartExecution(env, "internal/main/watch_mode"); |
361 | 362 | } |
362 | 363 |
|
363 | | - if (!env->options()->run.empty()) { |
364 | | - return StartExecution(env, "internal/main/run"); |
365 | | - } |
366 | | - |
367 | 364 | if (!first_argv.empty() && first_argv != "-") { |
368 | 365 | return StartExecution(env, "internal/main/run_main_module"); |
369 | 366 | } |
@@ -976,11 +973,11 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv, |
976 | 973 | InitializeNodeWithArgsInternal(argv, exec_argv, errors, flags)); |
977 | 974 | } |
978 | 975 |
|
979 | | -static std::unique_ptr<InitializationResultImpl> |
| 976 | +static std::shared_ptr<InitializationResultImpl> |
980 | 977 | InitializeOncePerProcessInternal(const std::vector<std::string>& args, |
981 | 978 | ProcessInitializationFlags::Flags flags = |
982 | 979 | ProcessInitializationFlags::kNoFlags) { |
983 | | - auto result = std::make_unique<InitializationResultImpl>(); |
| 980 | + auto result = std::make_shared<InitializationResultImpl>(); |
984 | 981 | result->args_ = args; |
985 | 982 |
|
986 | 983 | if (!(flags & ProcessInitializationFlags::kNoParseGlobalDebugVariables)) { |
@@ -1010,6 +1007,22 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args, |
1010 | 1007 | } |
1011 | 1008 | } |
1012 | 1009 |
|
| 1010 | + if (!per_process::cli_options->run.empty()) { |
| 1011 | + // TODO(@anonrig): Handle NODE_NO_WARNINGS, NODE_REDIRECT_WARNINGS, |
| 1012 | + // --disable-warning and --redirect-warnings. |
| 1013 | + if (per_process::cli_options->per_isolate->per_env->warnings) { |
| 1014 | + fprintf(stderr, |
| 1015 | + "ExperimentalWarning: Task runner is an experimental feature and " |
| 1016 | + "might change at any time\n\n"); |
| 1017 | + } |
| 1018 | + |
| 1019 | + auto positional_args = task_runner::GetPositionalArgs(args); |
| 1020 | + result->early_return_ = true; |
| 1021 | + task_runner::RunTask( |
| 1022 | + result, per_process::cli_options->run, positional_args); |
| 1023 | + return result; |
| 1024 | + } |
| 1025 | + |
1013 | 1026 | if (!(flags & ProcessInitializationFlags::kNoPrintHelpOrVersionOutput)) { |
1014 | 1027 | if (per_process::cli_options->print_version) { |
1015 | 1028 | printf("%s\n", NODE_VERSION); |
@@ -1169,7 +1182,7 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args, |
1169 | 1182 | return result; |
1170 | 1183 | } |
1171 | 1184 |
|
1172 | | -std::unique_ptr<InitializationResult> InitializeOncePerProcess( |
| 1185 | +std::shared_ptr<InitializationResult> InitializeOncePerProcess( |
1173 | 1186 | const std::vector<std::string>& args, |
1174 | 1187 | ProcessInitializationFlags::Flags flags) { |
1175 | 1188 | return InitializeOncePerProcessInternal(args, flags); |
@@ -1375,7 +1388,7 @@ static ExitCode StartInternal(int argc, char** argv) { |
1375 | 1388 | // Hack around with the argv pointer. Used for process.title = "blah". |
1376 | 1389 | argv = uv_setup_args(argc, argv); |
1377 | 1390 |
|
1378 | | - std::unique_ptr<InitializationResultImpl> result = |
| 1391 | + std::shared_ptr<InitializationResultImpl> result = |
1379 | 1392 | InitializeOncePerProcessInternal( |
1380 | 1393 | std::vector<std::string>(argv, argv + argc)); |
1381 | 1394 | for (const std::string& error : result->errors()) { |
|
0 commit comments