зеркало из https://github.com/electron/electron.git
refactor: prefer embedder-focused InitializeNodeWithArgs (#28271)
This commit is contained in:
Родитель
703f8707db
Коммит
96ce59609d
|
@ -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<base::Environment> 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<std::string>* argv,
|
||||
// std::vector<std::string>* exec_argv)
|
||||
node::Init(&argc, argv, &exec_argc, &exec_argv);
|
||||
std::vector<std::string> argv = {"electron"};
|
||||
std::vector<std::string> exec_argv;
|
||||
std::vector<std::string> 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
|
||||
|
|
Загрузка…
Ссылка в новой задаче