Skip to content

Commit a770a35

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/node.h

+10
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,20 @@ NODE_EXTERN int Stop(Environment* env);
223223

224224
// TODO(addaleax): Officially deprecate this and replace it with something
225225
// better suited for a public embedder API.
226+
// It is recommended to use InitializeNodeWithArgs() instead as an embedder.
227+
// Init() calls InitializeNodeWithArgs() and exits the process with the exit
228+
// code returned from it.
226229
NODE_EXTERN void Init(int* argc,
227230
const char** argv,
228231
int* exec_argc,
229232
const char*** exec_argv);
233+
// Set up per-process state needed to run Node.js. This will consume arguments
234+
// from argv, fill exec_argv, and possibly add errors resulting from parsing
235+
// the arguments to `errors`. The return value is a suggested exit code for the
236+
// program; If it is 0, then initializing Node.js succeeded.
237+
NODE_EXTERN int InitializeNodeWithArgs(std::vector<std::string>* argv,
238+
std::vector<std::string>* exec_argv,
239+
std::vector<std::string>* errors);
230240

231241
enum OptionEnvvarSettings {
232242
kAllowedInEnvironment,

0 commit comments

Comments
 (0)