diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 7db58675e5..8f36ce62de 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -363,21 +363,22 @@ void NodeBindings::Initialize() { // Parse and set Node.js cli flags. SetNodeCliFlags(); - // pass non-null program name to argv so it doesn't crash - // trying to index into a nullptr - int argc = 1; - int exec_argc = 0; - const char* prog_name = "electron"; - const char** argv = &prog_name; - const char** exec_argv = nullptr; - std::unique_ptr env(base::Environment::Create()); SetNodeOptions(env.get()); - // TODO(codebytere): this is going to be deprecated in the near future - // in favor of Init(std::vector* argv, - // std::vector* exec_argv) - node::Init(&argc, argv, &exec_argc, &exec_argv); + std::vector argv = {"electron"}; + std::vector exec_argv; + std::vector errors; + + int exit_code = node::InitializeNodeWithArgs(&argv, &exec_argv, &errors); + + for (const std::string& error : errors) { + fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str()); + } + + if (exit_code != 0) { + exit(exit_code); + } #if defined(OS_WIN) // uv_init overrides error mode to suppress the default crash dialog, bring