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 8809adf

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 Backport-PR-URL: #45994 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 cfb18d8 commit 8809adf
Copy full SHA for 8809adf

File tree

Expand file treeCollapse file tree

7 files changed

+177
-162
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+177
-162
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
@@ -277,14 +277,14 @@ const trailingValuesRegex = /=.*$/;
277277
// from data in the config binding.
278278
function buildAllowedFlags() {
279279
const {
280-
envSettings: { kAllowedInEnvironment },
280+
envSettings: { kAllowedInEnvvar },
281281
types: { kBoolean },
282282
} = internalBinding('options');
283283
const { options, aliases } = require('internal/options');
284284

285285
const allowedNodeEnvironmentFlags = [];
286286
for (const { 0: name, 1: info } of options) {
287-
if (info.envVarSettings === kAllowedInEnvironment) {
287+
if (info.envVarSettings === kAllowedInEnvvar) {
288288
ArrayPrototypePush(allowedNodeEnvironmentFlags, name);
289289
if (info.type === kBoolean) {
290290
const negatedName = `--no-${name.slice(2)}`;
@@ -301,7 +301,7 @@ function buildAllowedFlags() {
301301
ArrayPrototypeSplice(recursiveExpansion, 0, 1);
302302
return ArrayPrototypeEvery(recursiveExpansion, isAccepted);
303303
}
304-
return options.get(to).envVarSettings === kAllowedInEnvironment;
304+
return options.get(to).envVarSettings === kAllowedInEnvvar;
305305
}
306306
for (const { 0: from, 1: expansion } of aliases) {
307307
if (ArrayPrototypeEvery(expansion, isAccepted)) {
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
817817
const int exit_code = ProcessGlobalArgs(&env_argv,
818818
nullptr,
819819
errors,
820-
kAllowedInEnvironment);
820+
kAllowedInEnvvar);
821821
if (exit_code != 0) return exit_code;
822822
}
823823
}
@@ -827,7 +827,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
827827
const int exit_code = ProcessGlobalArgs(argv,
828828
exec_argv,
829829
errors,
830-
kDisallowedInEnvironment);
830+
kDisallowedInEnvvar);
831831
if (exit_code != 0) return exit_code;
832832
}
833833

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
@@ -361,10 +361,25 @@ inline std::unique_ptr<InitializationResult> InitializeOncePerProcess(
361361
}
362362

363363
enum OptionEnvvarSettings {
364-
kAllowedInEnvironment,
365-
kDisallowedInEnvironment
364+
// Allow the options to be set via the environment variable, like
365+
// `NODE_OPTIONS`.
366+
kAllowedInEnvvar = 0,
367+
// Disallow the options to be set via the environment variable, like
368+
// `NODE_OPTIONS`.
369+
kDisallowedInEnvvar = 1,
370+
// Deprecated, use kAllowedInEnvvar instead.
371+
kAllowedInEnvironment = kAllowedInEnvvar,
372+
// Deprecated, use kDisallowedInEnvvar instead.
373+
kDisallowedInEnvironment = kDisallowedInEnvvar,
366374
};
367375

376+
// Process the arguments and set up the per-process options.
377+
// If the `settings` is set as OptionEnvvarSettings::kAllowedInEnvvar, the
378+
// options that are allowed in the environment variable are processed. Options
379+
// that are disallowed to be set via environment variable are processed as
380+
// errors.
381+
// Otherwise all the options that are disallowed (and those are allowed) to be
382+
// set via environment variable are processed.
368383
NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args,
369384
std::vector<std::string>* exec_args,
370385
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.