From cc59531dd557a76694a1c969fb528db4cd5fc5c9 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 20 May 2021 14:53:10 +0200 Subject: [PATCH] src: make InitializeNodeWithArgs() official public API https://github.com/nodejs/node/pull/30467 --- shell/app/node_main.cc | 13 +++++++------ shell/common/node_bindings.cc | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index 02c176213e841..f9bbf1d5fa27a 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -172,9 +172,13 @@ int NodeMain(int argc, char* argv[]) { // Parse and set Node.js cli flags. SetNodeCliFlags(); - int exec_argc; - const char** exec_argv; - node::Init(&argc, const_cast(argv), &exec_argc, &exec_argv); + std::vector args(argv, argv + argc); // NOLINT + std::vector exec_args; + std::vector errors; + node::InitializeNodeWithArgs(&args, &exec_args, &errors); + + for (const std::string& error : errors) + fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str()); gin::V8Initializer::LoadV8Snapshot( gin::V8Initializer::V8SnapshotFileType::kWithAdditionalContext); @@ -201,9 +205,6 @@ int NodeMain(int argc, char* argv[]) { isolate_data = node::CreateIsolateData(isolate, loop, gin_env.platform()); CHECK_NE(nullptr, isolate_data); - std::vector args(argv, argv + argc); // NOLINT - std::vector exec_args(exec_argv, - exec_argv + exec_argc); // NOLINT env = node::CreateEnvironment(isolate_data, gin_env.context(), args, exec_args); CHECK_NOT_NULL(env); diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 0945139f07db8..45c93db91e4db 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -378,9 +378,8 @@ void NodeBindings::Initialize() { fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str()); } - if (exit_code != 0) { + if (exit_code != 0) exit(exit_code); - } #if defined(OS_WIN) // uv_init overrides error mode to suppress the default crash dialog, bring