Skip to content

Commit 036a982

Browse files
codebytereMylesBorins
authored andcommitted
src: expose ability to set options
PR-URL: #30466 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b99eca9 commit 036a982

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

src/node.cc

+10-6
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@
112112
namespace node {
113113

114114
using native_module::NativeModuleEnv;
115-
using options_parser::kAllowedInEnvironment;
116-
using options_parser::kDisallowedInEnvironment;
117115

118116
using v8::Boolean;
119117
using v8::EscapableHandleScope;
@@ -631,7 +629,7 @@ void ResetStdio() {
631629
int ProcessGlobalArgs(std::vector<std::string>* args,
632630
std::vector<std::string>* exec_args,
633631
std::vector<std::string>* errors,
634-
bool is_env) {
632+
OptionEnvvarSettings settings) {
635633
// Parse a few arguments which are specific to Node.
636634
std::vector<std::string> v8_args;
637635

@@ -641,7 +639,7 @@ int ProcessGlobalArgs(std::vector<std::string>* args,
641639
exec_args,
642640
&v8_args,
643641
per_process::cli_options.get(),
644-
is_env ? kAllowedInEnvironment : kDisallowedInEnvironment,
642+
settings,
645643
errors);
646644

647645
if (!errors->empty()) return 9;
@@ -803,12 +801,18 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
803801
return 9;
804802
}
805803

806-
const int exit_code = ProcessGlobalArgs(&env_argv, nullptr, errors, true);
804+
const int exit_code = ProcessGlobalArgs(&env_argv,
805+
nullptr,
806+
errors,
807+
kAllowedInEnvironment);
807808
if (exit_code != 0) return exit_code;
808809
}
809810
#endif
810811

811-
const int exit_code = ProcessGlobalArgs(argv, exec_argv, errors, false);
812+
const int exit_code = ProcessGlobalArgs(argv,
813+
exec_argv,
814+
errors,
815+
kDisallowedInEnvironment);
812816
if (exit_code != 0) return exit_code;
813817

814818
// Set the process.title immediately after processing argv if --title is set.

src/node.h

+10
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ NODE_EXTERN void Init(int* argc,
219219
int* exec_argc,
220220
const char*** exec_argv);
221221

222+
enum OptionEnvvarSettings {
223+
kAllowedInEnvironment,
224+
kDisallowedInEnvironment
225+
};
226+
227+
NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
228+
std::vector<std::string>* exec_args,
229+
std::vector<std::string>* errors,
230+
OptionEnvvarSettings settings);
231+
222232
class NodeArrayBufferAllocator;
223233

224234
// An ArrayBuffer::Allocator class with some Node.js-specific tweaks. If you do

src/node_options.h

-5
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,6 @@ HostPort SplitHostPort(const std::string& arg,
251251
std::vector<std::string>* errors);
252252
void GetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
253253

254-
enum OptionEnvvarSettings {
255-
kAllowedInEnvironment,
256-
kDisallowedInEnvironment
257-
};
258-
259254
enum OptionType {
260255
kNoOp,
261256
kV8Option,

src/node_worker.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <string>
1717
#include <vector>
1818

19-
using node::options_parser::kDisallowedInEnvironment;
19+
using node::kDisallowedInEnvironment;
2020
using v8::Array;
2121
using v8::ArrayBuffer;
2222
using v8::Boolean;

0 commit comments

Comments
 (0)