Skip to content

Commit 2c8276e

Browse files
codebytereBridgeAR
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 c464ede commit 2c8276e

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
@@ -123,8 +123,6 @@
123123
namespace node {
124124

125125
using native_module::NativeModuleEnv;
126-
using options_parser::kAllowedInEnvironment;
127-
using options_parser::kDisallowedInEnvironment;
128126

129127
using v8::Boolean;
130128
using v8::EscapableHandleScope;
@@ -679,7 +677,7 @@ void ResetStdio() {
679677
int ProcessGlobalArgs(std::vector<std::string>* args,
680678
std::vector<std::string>* exec_args,
681679
std::vector<std::string>* errors,
682-
bool is_env) {
680+
OptionEnvvarSettings settings) {
683681
// Parse a few arguments which are specific to Node.
684682
std::vector<std::string> v8_args;
685683

@@ -689,7 +687,7 @@ int ProcessGlobalArgs(std::vector<std::string>* args,
689687
exec_args,
690688
&v8_args,
691689
per_process::cli_options.get(),
692-
is_env ? kAllowedInEnvironment : kDisallowedInEnvironment,
690+
settings,
693691
errors);
694692

695693
if (!errors->empty()) return 9;
@@ -851,12 +849,18 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
851849
return 9;
852850
}
853851

854-
const int exit_code = ProcessGlobalArgs(&env_argv, nullptr, errors, true);
852+
const int exit_code = ProcessGlobalArgs(&env_argv,
853+
nullptr,
854+
errors,
855+
kAllowedInEnvironment);
855856
if (exit_code != 0) return exit_code;
856857
}
857858
#endif
858859

859-
const int exit_code = ProcessGlobalArgs(argv, exec_argv, errors, false);
860+
const int exit_code = ProcessGlobalArgs(argv,
861+
exec_argv,
862+
errors,
863+
kDisallowedInEnvironment);
860864
if (exit_code != 0) return exit_code;
861865

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

src/node.h

+10
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,16 @@ NODE_EXTERN void Init(int* argc,
225225
int* exec_argc,
226226
const char*** exec_argv);
227227

228+
enum OptionEnvvarSettings {
229+
kAllowedInEnvironment,
230+
kDisallowedInEnvironment
231+
};
232+
233+
NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
234+
std::vector<std::string>* exec_args,
235+
std::vector<std::string>* errors,
236+
OptionEnvvarSettings settings);
237+
228238
class NodeArrayBufferAllocator;
229239

230240
// 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
@@ -247,11 +247,6 @@ HostPort SplitHostPort(const std::string& arg,
247247
std::vector<std::string>* errors);
248248
void GetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
249249

250-
enum OptionEnvvarSettings {
251-
kAllowedInEnvironment,
252-
kDisallowedInEnvironment
253-
};
254-
255250
enum OptionType {
256251
kNoOp,
257252
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)