| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cfb18d8 commit 8809adf
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,14 +277,14 @@ const trailingValuesRegex = /=.*$/; | |||
| 277 | 277 | // from data in the config binding. | |
| 278 | 278 | function buildAllowedFlags() { | |
| 279 | 279 | const { | |
| 280 | - envSettings: { kAllowedInEnvironment }, | ||
| 280 | + envSettings: { kAllowedInEnvvar }, | ||
| 281 | 281 | types: { kBoolean }, | |
| 282 | 282 | } = internalBinding('options'); | |
| 283 | 283 | const { options, aliases } = require('internal/options'); | |
| 284 | 284 | ||
| 285 | 285 | const allowedNodeEnvironmentFlags = []; | |
| 286 | 286 | for (const { 0: name, 1: info } of options) { | |
| 287 | - if (info.envVarSettings === kAllowedInEnvironment) { | ||
| 287 | + if (info.envVarSettings === kAllowedInEnvvar) { | ||
| 288 | 288 | ArrayPrototypePush(allowedNodeEnvironmentFlags, name); | |
| 289 | 289 | if (info.type === kBoolean) { | |
| 290 | 290 | const negatedName = `--no-${name.slice(2)}`; | |
@@ -301,7 +301,7 @@ function buildAllowedFlags() { | |||
| 301 | 301 | ArrayPrototypeSplice(recursiveExpansion, 0, 1); | |
| 302 | 302 | return ArrayPrototypeEvery(recursiveExpansion, isAccepted); | |
| 303 | 303 | } | |
| 304 | - return options.get(to).envVarSettings === kAllowedInEnvironment; | ||
| 304 | + return options.get(to).envVarSettings === kAllowedInEnvvar; | ||
| 305 | 305 | } | |
| 306 | 306 | for (const { 0: from, 1: expansion } of aliases) { | |
| 307 | 307 | if (ArrayPrototypeEvery(expansion, isAccepted)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -817,7 +817,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv, | |||
| 817 | 817 | const int exit_code = ProcessGlobalArgs(&env_argv, | |
| 818 | 818 | nullptr, | |
| 819 | 819 | errors, | |
| 820 | - kAllowedInEnvironment); | ||
| 820 | + kAllowedInEnvvar); | ||
| 821 | 821 | if (exit_code != 0) return exit_code; | |
| 822 | 822 | } | |
| 823 | 823 | } | |
@@ -827,7 +827,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv, | |||
| 827 | 827 | const int exit_code = ProcessGlobalArgs(argv, | |
| 828 | 828 | exec_argv, | |
| 829 | 829 | errors, | |
| 830 | - kDisallowedInEnvironment); | ||
| 830 | + kDisallowedInEnvvar); | ||
| 831 | 831 | if (exit_code != 0) return exit_code; | |
| 832 | 832 | } | |
| 833 | 833 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -361,10 +361,25 @@ inline std::unique_ptr<InitializationResult> InitializeOncePerProcess( | |||
| 361 | 361 | } | |
| 362 | 362 | ||
| 363 | 363 | 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, | ||
| 366 | 374 | }; | |
| 367 | 375 | ||
| 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. | ||
| 368 | 383 | NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args, | |
| 369 | 384 | std::vector<std::string>* exec_args, | |
| 370 | 385 | std::vector<std::string>* errors, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -302,7 +302,7 @@ void OptionsParser<Options>::Parse( | |||
| 302 | 302 | const std::string arg = args.pop_first(); | |
| 303 | 303 | ||
| 304 | 304 | if (arg == "--") { | |
| 305 | - if (required_env_settings == kAllowedInEnvironment) | ||
| 305 | + if (required_env_settings == kAllowedInEnvvar) | ||
| 306 | 306 | errors->push_back(NotAllowedInEnvErr("--")); | |
| 307 | 307 | break; | |
| 308 | 308 | } | |
@@ -374,8 +374,8 @@ void OptionsParser<Options>::Parse( | |||
| 374 | 374 | auto it = options_.find(name); | |
| 375 | 375 | ||
| 376 | 376 | 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) { | ||
| 379 | 379 | errors->push_back(NotAllowedInEnvErr(original_name)); | |
| 380 | 380 | break; | |
| 381 | 381 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments