Skip to content

Commit 8dfba84

Browse files
committed
src: clarify OptionEnvvarSettings member names
The term `Environment` in `kAllowedInEnvironment` and `kDisallowedInEnvironment` has nothing to do with the commonly used term `node::Environment`. Rename the member to `kAllowedInNodeOptions` and `kDisallowedInNodeOptions` respectively to reflect they are options of `OptionEnvvarSettings`. As `OptionEnvvarSettings` is part of the public embedder APIs, the legacy names are still preserved.
1 parent 6bdc101 commit 8dfba84

File tree

7 files changed

+165
-161
lines changed

7 files changed

+165
-161
lines changed

lib/internal/process/per_thread.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ const trailingValuesRegex = /=.*$/;
267267
// from data in the config binding.
268268
function buildAllowedFlags() {
269269
const {
270-
envSettings: { kAllowedInEnvironment },
270+
envSettings: { kAllowedInNodeOptions },
271271
types: { kBoolean },
272272
} = internalBinding('options');
273273
const { options, aliases } = require('internal/options');
274274

275275
const allowedNodeEnvironmentFlags = [];
276276
for (const { 0: name, 1: info } of options) {
277-
if (info.envVarSettings === kAllowedInEnvironment) {
277+
if (info.envVarSettings === kAllowedInNodeOptions) {
278278
ArrayPrototypePush(allowedNodeEnvironmentFlags, name);
279279
if (info.type === kBoolean) {
280280
const negatedName = `--no-${name.slice(2)}`;
@@ -291,7 +291,7 @@ function buildAllowedFlags() {
291291
ArrayPrototypeSplice(recursiveExpansion, 0, 1);
292292
return ArrayPrototypeEvery(recursiveExpansion, isAccepted);
293293
}
294-
return options.get(to).envVarSettings === kAllowedInEnvironment;
294+
return options.get(to).envVarSettings === kAllowedInNodeOptions;
295295
}
296296
for (const { 0: from, 1: expansion } of aliases) {
297297
if (ArrayPrototypeEvery(expansion, isAccepted)) {

src/node.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,15 @@ static ExitCode InitializeNodeWithArgsInternal(
769769
env_argv.insert(env_argv.begin(), argv->at(0));
770770

771771
const ExitCode exit_code = ProcessGlobalArgsInternal(
772-
&env_argv, nullptr, errors, kAllowedInEnvironment);
772+
&env_argv, nullptr, errors, kAllowedInNodeOptions);
773773
if (exit_code != ExitCode::kNoFailure) return exit_code;
774774
}
775775
}
776776
#endif
777777

778778
if (!(flags & ProcessInitializationFlags::kDisableCLIOptions)) {
779779
const ExitCode exit_code = ProcessGlobalArgsInternal(
780-
argv, exec_argv, errors, kDisallowedInEnvironment);
780+
argv, exec_argv, errors, kDisallowedInNodeOptions);
781781
if (exit_code != ExitCode::kNoFailure) return exit_code;
782782
}
783783

src/node.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,12 @@ inline std::unique_ptr<InitializationResult> InitializeOncePerProcess(
349349
}
350350

351351
enum OptionEnvvarSettings {
352-
kAllowedInEnvironment,
353-
kDisallowedInEnvironment
352+
kAllowedInNodeOptions = 0,
353+
kDisallowedInNodeOptions = 1,
354+
// Deprecated, use kAllowedInNodeOptions instead.
355+
kAllowedInEnvironment = kAllowedInNodeOptions,
356+
// Deprecated, use kDisallowedInNodeOptions instead.
357+
kDisallowedInEnvironment = kDisallowedInNodeOptions,
354358
};
355359

356360
NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,

src/node_options-inl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void OptionsParser<Options>::Parse(
302302
const std::string arg = args.pop_first();
303303

304304
if (arg == "--") {
305-
if (required_env_settings == kAllowedInEnvironment)
305+
if (required_env_settings == kAllowedInNodeOptions)
306306
errors->push_back(NotAllowedInEnvErr("--"));
307307
break;
308308
}
@@ -374,8 +374,8 @@ void OptionsParser<Options>::Parse(
374374
auto it = options_.find(name);
375375

376376
if ((it == options_.end() ||
377-
it->second.env_setting == kDisallowedInEnvironment) &&
378-
required_env_settings == kAllowedInEnvironment) {
377+
it->second.env_setting == kDisallowedInNodeOptions) &&
378+
required_env_settings == kAllowedInNodeOptions) {
379379
errors->push_back(NotAllowedInEnvErr(original_name));
380380
break;
381381
}

0 commit comments

Comments
 (0)