| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8f8d7e7 commit 243c141
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -283,14 +283,14 @@ const trailingValuesRegex = /=.*$/; | |||
| 283 | 283 | // from data in the config binding. | |
| 284 | 284 | function buildAllowedFlags() { | |
| 285 | 285 | const { | |
| 286 | - envSettings: { kAllowedInEnvironment }, | ||
| 286 | + envSettings: { kAllowedInEnvvar }, | ||
| 287 | 287 | types: { kBoolean }, | |
| 288 | 288 | } = internalBinding('options'); | |
| 289 | 289 | const { options, aliases } = require('internal/options'); | |
| 290 | 290 | ||
| 291 | 291 | const allowedNodeEnvironmentFlags = []; | |
| 292 | 292 | for (const { 0: name, 1: info } of options) { | |
| 293 | - if (info.envVarSettings === kAllowedInEnvironment) { | ||
| 293 | + if (info.envVarSettings === kAllowedInEnvvar) { | ||
| 294 | 294 | ArrayPrototypePush(allowedNodeEnvironmentFlags, name); | |
| 295 | 295 | if (info.type === kBoolean) { | |
| 296 | 296 | const negatedName = `--no-${name.slice(2)}`; | |
@@ -307,7 +307,7 @@ function buildAllowedFlags() { | |||
| 307 | 307 | ArrayPrototypeSplice(recursiveExpansion, 0, 1); | |
| 308 | 308 | return ArrayPrototypeEvery(recursiveExpansion, isAccepted); | |
| 309 | 309 | } | |
| 310 | - return options.get(to).envVarSettings === kAllowedInEnvironment; | ||
| 310 | + return options.get(to).envVarSettings === kAllowedInEnvvar; | ||
| 311 | 311 | } | |
| 312 | 312 | for (const { 0: from, 1: expansion } of aliases) { | |
| 313 | 313 | if (ArrayPrototypeEvery(expansion, isAccepted)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -790,15 +790,15 @@ static ExitCode InitializeNodeWithArgsInternal( | |||
| 790 | 790 | env_argv.insert(env_argv.begin(), argv->at(0)); | |
| 791 | 791 | ||
| 792 | 792 | const ExitCode exit_code = ProcessGlobalArgsInternal( | |
| 793 | - &env_argv, nullptr, errors, kAllowedInEnvironment); | ||
| 793 | + &env_argv, nullptr, errors, kAllowedInEnvvar); | ||
| 794 | 794 | if (exit_code != ExitCode::kNoFailure) return exit_code; | |
| 795 | 795 | } | |
| 796 | 796 | } | |
| 797 | 797 | #endif | |
| 798 | 798 | ||
| 799 | 799 | 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); | ||
| 802 | 802 | if (exit_code != ExitCode::kNoFailure) return exit_code; | |
| 803 | 803 | } | |
| 804 | 804 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -349,10 +349,25 @@ inline std::unique_ptr<InitializationResult> InitializeOncePerProcess( | |||
| 349 | 349 | } | |
| 350 | 350 | ||
| 351 | 351 | 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, | ||
| 354 | 362 | }; | |
| 355 | 363 | ||
| 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. | ||
| 356 | 371 | NODE_EXTERN int ProcessGlobalArgs(std::vector<std::string>* args, | |
| 357 | 372 | std::vector<std::string>* exec_args, | |
| 358 | 373 | 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