From a770a35f612672394bc456c2fec336e2c6e6fbed Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 27 Feb 2020 17:40:54 -0800 Subject: [PATCH] src: make InitializeNodeWithArgs() official public API This is a decent replacement for the to-be-deprecated Init() API. Backport-PR-URL: https://github.com/nodejs/node/pull/35241 PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil --- src/node.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/node.h b/src/node.h index 10a64744450bc8..7a8709f7d624ea 100644 --- a/src/node.h +++ b/src/node.h @@ -223,10 +223,20 @@ NODE_EXTERN int Stop(Environment* env); // TODO(addaleax): Officially deprecate this and replace it with something // better suited for a public embedder API. +// It is recommended to use InitializeNodeWithArgs() instead as an embedder. +// Init() calls InitializeNodeWithArgs() and exits the process with the exit +// code returned from it. NODE_EXTERN void Init(int* argc, const char** argv, int* exec_argc, const char*** exec_argv); +// Set up per-process state needed to run Node.js. This will consume arguments +// from argv, fill exec_argv, and possibly add errors resulting from parsing +// the arguments to `errors`. The return value is a suggested exit code for the +// program; If it is 0, then initializing Node.js succeeded. +NODE_EXTERN int InitializeNodeWithArgs(std::vector* argv, + std::vector* exec_argv, + std::vector* errors); enum OptionEnvvarSettings { kAllowedInEnvironment,