Skip to content

Commit

Permalink
src: clarify OptionEnvvarSettings member names
Browse files Browse the repository at this point in the history
The term `Environment` in `kAllowedInEnvironment` and
`kDisallowedInEnvironment` has nothing to do with the commonly used
term `node::Environment`. Rename the member to `kAllowedInEnvvar` and
`kDisallowedInEnvvar` respectively to reflect they are options of
`OptionEnvvarSettings`.

As `OptionEnvvarSettings` is part of the public embedder APIs, the
legacy names are still preserved.
  • Loading branch information
legendecas committed Oct 18, 2022
1 parent 9878c26 commit 1563488
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 162 deletions.
6 changes: 3 additions & 3 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -769,15 +769,15 @@ static ExitCode InitializeNodeWithArgsInternal(
env_argv.insert(env_argv.begin(), argv->at(0));

const ExitCode exit_code = ProcessGlobalArgsInternal(
&env_argv, nullptr, errors, kAllowedInEnvironment);
&env_argv, nullptr, errors, kAllowedInEnvvar);
if (exit_code != ExitCode::kNoFailure) return exit_code;
}
}
#endif

if (!(flags & ProcessInitializationFlags::kDisableCLIOptions)) {
const ExitCode exit_code = ProcessGlobalArgsInternal(
argv, exec_argv, errors, kDisallowedInEnvironment);
const ExitCode exit_code =
ProcessGlobalArgsInternal(argv, exec_argv, errors, kDisallowedInEnvvar);
if (exit_code != ExitCode::kNoFailure) return exit_code;
}

Expand Down
8 changes: 6 additions & 2 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,12 @@ inline std::unique_ptr<InitializationResult> InitializeOncePerProcess(
}

enum OptionEnvvarSettings {
kAllowedInEnvironment,
kDisallowedInEnvironment
kAllowedInEnvvar = 0,
kDisallowedInEnvvar = 1,
// Deprecated, use kAllowedInEnvvar instead.
kAllowedInEnvironment = kAllowedInEnvvar,
// Deprecated, use kDisallowedInEnvvar instead.
kDisallowedInEnvironment = kDisallowedInEnvvar,
};

NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
Expand Down
6 changes: 3 additions & 3 deletions src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void OptionsParser<Options>::Parse(
const std::string arg = args.pop_first();

if (arg == "--") {
if (required_env_settings == kAllowedInEnvironment)
if (required_env_settings == kAllowedInEnvvar)
errors->push_back(NotAllowedInEnvErr("--"));
break;
}
Expand Down Expand Up @@ -374,8 +374,8 @@ void OptionsParser<Options>::Parse(
auto it = options_.find(name);

if ((it == options_.end() ||
it->second.env_setting == kDisallowedInEnvironment) &&
required_env_settings == kAllowedInEnvironment) {
it->second.env_setting == kDisallowedInEnvvar) &&
required_env_settings == kAllowedInEnvvar) {
errors->push_back(NotAllowedInEnvErr(original_name));
break;
}
Expand Down
Loading

0 comments on commit 1563488

Please sign in to comment.