@@ -37,15 +37,18 @@ the `node` and `v8` C++ namespaces, respectively. |
37 | 37 | int main(int argc, char** argv) { |
38 | 38 | argv = uv_setup_args(argc, argv); |
39 | 39 | std::vector<std::string> args(argv, argv + argc); |
40 | | - std::vector<std::string> exec_args; |
41 | | - std::vector<std::string> errors; |
42 | 40 | // Parse Node.js CLI options, and print any errors that have occurred while |
43 | 41 | // trying to parse them. |
44 | | - int exit_code = node::InitializeNodeWithArgs(&args, &exec_args, &errors); |
45 | | - for (const std::string& error : errors) |
| 42 | + std::unique_ptr<node::InitializationResult> result = |
| 43 | + node::InitializeOncePerProcess(args, { |
| 44 | + node::ProcessInitializationFlags::kNoInitializeV8, |
| 45 | + node::ProcessInitializationFlags::kNoInitializeNodeV8Platform |
| 46 | + }); |
| 47 | + |
| 48 | + for (const std::string& error : result->errors()) |
46 | 49 | fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str()); |
47 | | - if (exit_code != 0) { |
48 | | - return exit_code; |
| 50 | + if (result->early_return() != 0) { |
| 51 | + return result->exit_code(); |
49 | 52 | } |
50 | 53 |
|
51 | 54 | // Create a v8::Platform instance. `MultiIsolatePlatform::Create()` is a way |
@@ -58,10 +61,13 @@ int main(int argc, char** argv) { |
58 | 61 | V8::Initialize(); |
59 | 62 |
|
60 | 63 | // See below for the contents of this function. |
61 | | - int ret = RunNodeInstance(platform.get(), args, exec_args); |
| 64 | + int ret = RunNodeInstance( |
| 65 | + platform.get(), result->args(), result->exec_args()); |
62 | 66 |
|
63 | 67 | V8::Dispose(); |
64 | 68 | V8::DisposePlatform(); |
| 69 | + |
| 70 | + node::TearDownOncePerProcess(); |
65 | 71 | return ret; |
66 | 72 | } |
67 | 73 | ``` |
|