Skip to content

Commit d7f1107

Browse files
committed
src: make InitializeNodeWithArgs() official public API
This is a decent replacement for the to-be-deprecated Init() API. PR-URL: #30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 821e21d commit d7f1107

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/node.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,20 @@ NODE_EXTERN int Stop(Environment* env);
229229

230230
// TODO(addaleax): Officially deprecate this and replace it with something
231231
// better suited for a public embedder API.
232+
// It is recommended to use InitializeNodeWithArgs() instead as an embedder.
233+
// Init() calls InitializeNodeWithArgs() and exits the process with the exit
234+
// code returned from it.
232235
NODE_EXTERN void Init(int* argc,
233236
const char** argv,
234237
int* exec_argc,
235238
const char*** exec_argv);
239+
// Set up per-process state needed to run Node.js. This will consume arguments
240+
// from argv, fill exec_argv, and possibly add errors resulting from parsing
241+
// the arguments to `errors`. The return value is a suggested exit code for the
242+
// program; If it is 0, then initializing Node.js succeeded.
243+
NODE_EXTERN int InitializeNodeWithArgs(std::vector<std::string>* argv,
244+
std::vector<std::string>* exec_argv,
245+
std::vector<std::string>* errors);
236246

237247
enum OptionEnvvarSettings {
238248
kAllowedInEnvironment,

0 commit comments

Comments
 (0)