Skip to content

Commit

Permalink
src: expose ability to set options
Browse files Browse the repository at this point in the history
PR-URL: nodejs#30466
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
codebytere committed Nov 18, 2019
1 parent 70281ce commit 0f58bfd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@
namespace node {

using native_module::NativeModuleEnv;
using options_parser::kAllowedInEnvironment;
using options_parser::kDisallowedInEnvironment;

using v8::Boolean;
using v8::EscapableHandleScope;
Expand Down Expand Up @@ -679,7 +677,7 @@ void ResetStdio() {
int ProcessGlobalArgs(std::vector<std::string>* args,
std::vector<std::string>* exec_args,
std::vector<std::string>* errors,
bool is_env) {
OptionEnvvarSettings settings) {
// Parse a few arguments which are specific to Node.
std::vector<std::string> v8_args;

Expand All @@ -689,7 +687,7 @@ int ProcessGlobalArgs(std::vector<std::string>* args,
exec_args,
&v8_args,
per_process::cli_options.get(),
is_env ? kAllowedInEnvironment : kDisallowedInEnvironment,
settings,
errors);

if (!errors->empty()) return 9;
Expand Down Expand Up @@ -851,12 +849,18 @@ int InitializeNodeWithArgs(std::vector<std::string>* 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.
Expand Down
10 changes: 10 additions & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>* args,
std::vector<std::string>* exec_args,
std::vector<std::string>* errors,
OptionEnvvarSettings settings);

class NodeArrayBufferAllocator;

// An ArrayBuffer::Allocator class with some Node.js-specific tweaks. If you do
Expand Down
5 changes: 0 additions & 5 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ HostPort SplitHostPort(const std::string& arg,
std::vector<std::string>* errors);
void GetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);

enum OptionEnvvarSettings {
kAllowedInEnvironment,
kDisallowedInEnvironment
};

enum OptionType {
kNoOp,
kV8Option,
Expand Down
2 changes: 1 addition & 1 deletion src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <string>
#include <vector>

using node::options_parser::kDisallowedInEnvironment;
using node::kDisallowedInEnvironment;
using v8::Array;
using v8::ArrayBuffer;
using v8::Boolean;
Expand Down

0 comments on commit 0f58bfd

Please sign in to comment.