From a3eb3b2f7ce70a44b37b3cdefcb5aecec0d54c8b Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 13 Nov 2019 15:53:19 +0000 Subject: [PATCH] src: expose ability to set options --- src/node.cc | 16 ++++++++++------ src/node.h | 10 ++++++++++ src/node_options.h | 5 ----- src/node_worker.cc | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/node.cc b/src/node.cc index 5a8e6ea8c07982..ed196433e321c2 100644 --- a/src/node.cc +++ b/src/node.cc @@ -123,8 +123,6 @@ namespace node { using native_module::NativeModuleEnv; -using options_parser::kAllowedInEnvironment; -using options_parser::kDisallowedInEnvironment; using v8::Boolean; using v8::EscapableHandleScope; @@ -678,7 +676,7 @@ void ResetStdio() { int ProcessGlobalArgs(std::vector* args, std::vector* exec_args, std::vector* errors, - bool is_env) { + OptionEnvvarSettings settings) { // Parse a few arguments which are specific to Node. std::vector v8_args; @@ -688,7 +686,7 @@ int ProcessGlobalArgs(std::vector* args, exec_args, &v8_args, per_process::cli_options.get(), - is_env ? kAllowedInEnvironment : kDisallowedInEnvironment, + settings, errors); if (!errors->empty()) return 9; @@ -850,12 +848,18 @@ int InitializeNodeWithArgs(std::vector* argv, return 9; } - const int exit_code = ProcessGlobalArgs(&env_argv, nullptr, errors, true); + const int exit_code = ProcessGlobalArgs(&env_argv, + nullptr, + errors, + kAllowedInEnvironment); if (exit_code != 0) return exit_code; } #endif - const int exit_code = ProcessGlobalArgs(argv, exec_argv, errors, false); + const int exit_code = ProcessGlobalArgs(argv, + exec_argv, + errors, + kDisallowedInEnvironment); if (exit_code != 0) return exit_code; // Set the process.title immediately after processing argv if --title is set. diff --git a/src/node.h b/src/node.h index f1e769a182e3c0..c80e6266857921 100644 --- a/src/node.h +++ b/src/node.h @@ -225,6 +225,16 @@ NODE_EXTERN void Init(int* argc, int* exec_argc, const char*** exec_argv); +enum OptionEnvvarSettings { + kAllowedInEnvironment, + kDisallowedInEnvironment +}; + +NODE_EXTERN int ProcessGlobalArgs(std::vector* args, + std::vector* exec_args, + std::vector* errors, + OptionEnvvarSettings settings); + class NodeArrayBufferAllocator; // An ArrayBuffer::Allocator class with some Node.js-specific tweaks. If you do diff --git a/src/node_options.h b/src/node_options.h index c36c0ad160c30f..30a976f48d5b4e 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -247,11 +247,6 @@ HostPort SplitHostPort(const std::string& arg, std::vector* errors); void GetOptions(const v8::FunctionCallbackInfo& args); -enum OptionEnvvarSettings { - kAllowedInEnvironment, - kDisallowedInEnvironment -}; - enum OptionType { kNoOp, kV8Option, diff --git a/src/node_worker.cc b/src/node_worker.cc index 72717331eeb8b2..9976ec3f0ac089 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -16,7 +16,7 @@ #include #include -using node::options_parser::kDisallowedInEnvironment; +using node::kDisallowedInEnvironment; using v8::Array; using v8::ArrayBuffer; using v8::Boolean;