Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 243c141

Browse filesBrowse files
legendecasRafaelGSS
authored andcommitted
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 `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. PR-URL: #45057 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 8f8d7e7 commit 243c141
Copy full SHA for 243c141

File tree

Expand file treeCollapse file tree

7 files changed

+175
-165
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+175
-165
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/per_thread.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/per_thread.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ const trailingValuesRegex = /=.*$/;
283283
// from data in the config binding.
284284
function buildAllowedFlags() {
285285
const {
286-
envSettings: { kAllowedInEnvironment },
286+
envSettings: { kAllowedInEnvvar },
287287
types: { kBoolean },
288288
} = internalBinding('options');
289289
const { options, aliases } = require('internal/options');
290290

291291
const allowedNodeEnvironmentFlags = [];
292292
for (const { 0: name, 1: info } of options) {
293-
if (info.envVarSettings === kAllowedInEnvironment) {
293+
if (info.envVarSettings === kAllowedInEnvvar) {
294294
ArrayPrototypePush(allowedNodeEnvironmentFlags, name);
295295
if (info.type === kBoolean) {
296296
const negatedName = `--no-${name.slice(2)}`;
@@ -307,7 +307,7 @@ function buildAllowedFlags() {
307307
ArrayPrototypeSplice(recursiveExpansion, 0, 1);
308308
return ArrayPrototypeEvery(recursiveExpansion, isAccepted);
309309
}
310-
return options.get(to).envVarSettings === kAllowedInEnvironment;
310+
return options.get(to).envVarSettings === kAllowedInEnvvar;
311311
}
312312
for (const { 0: from, 1: expansion } of aliases) {
313313
if (ArrayPrototypeEvery(expansion, isAccepted)) {
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,15 +790,15 @@ static ExitCode InitializeNodeWithArgsInternal(
790790
env_argv.insert(env_argv.begin(), argv->at(0));
791791

792792
const ExitCode exit_code = ProcessGlobalArgsInternal(
793-
&env_argv, nullptr, errors, kAllowedInEnvironment);
793+
&env_argv, nullptr, errors, kAllowedInEnvvar);
794794
if (exit_code != ExitCode::kNoFailure) return exit_code;
795795
}
796796
}
797797
#endif
798798

799799
if (!(flags & ProcessInitializationFlags::kDisableCLIOptions)) {
800-
const ExitCode exit_code = ProcessGlobalArgsInternal(
801-
argv, exec_argv, errors, kDisallowedInEnvironment);
800+
const ExitCode exit_code =
801+
ProcessGlobalArgsInternal(argv, exec_argv, errors, kDisallowedInEnvvar);
802802
if (exit_code != ExitCode::kNoFailure) return exit_code;
803803
}
804804

Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+17-2Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,25 @@ inline std::unique_ptr<InitializationResult> InitializeOncePerProcess(
349349
}
350350

351351
enum OptionEnvvarSettings {
352-
kAllowedInEnvironment,
353-
kDisallowedInEnvironment
352+
// Allow the options to be set via the environment variable, like
353+
// `NODE_OPTIONS`.
354+
kAllowedInEnvvar = 0,
355+
// Disallow the options to be set via the environment variable, like
356+
// `NODE_OPTIONS`.
357+
kDisallowedInEnvvar = 1,
358+
// Deprecated, use kAllowedInEnvvar instead.
359+
kAllowedInEnvironment = kAllowedInEnvvar,
360+
// Deprecated, use kDisallowedInEnvvar instead.
361+
kDisallowedInEnvironment = kDisallowedInEnvvar,
354362
};
355363

364+
// Process the arguments and set up the per-process options.
365+
// If the `settings` is set as OptionEnvvarSettings::kAllowedInEnvvar, the
366+
// options that are allowed in the environment variable are processed. Options
367+
// that are disallowed to be set via environment variable are processed as
368+
// errors.
369+
// Otherwise all the options that are disallowed (and those are allowed) to be
370+
// set via environment variable are processed.
356371
NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
357372
std::vector<std::string>* exec_args,
358373
std::vector<std::string>* errors,
Collapse file

‎src/node_options-inl.h‎

Copy file name to clipboardExpand all lines: src/node_options-inl.h
+3-3Lines changed: 3 additions & 3 deletions
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 == kAllowedInEnvvar)
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 == kDisallowedInEnvvar) &&
378+
required_env_settings == kAllowedInEnvvar) {
379379
errors->push_back(NotAllowedInEnvErr(original_name));
380380
break;
381381
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.