| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 14fc4dd commit f793380
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -128,7 +128,7 @@ function setupWarningHandler() { | |||
| 128 | 128 | const { | |
| 129 | 129 | onWarning | |
| 130 | 130 | } = require('internal/process/warning'); | |
| 131 | - if (!getOptionValue('--no-warnings') && | ||
| 131 | + if (getOptionValue('--warnings') && | ||
| 132 | 132 | process.env.NODE_NO_WARNINGS !== '1') { | |
| 133 | 133 | process.on('warning', onWarning); | |
| 134 | 134 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,8 @@ const { | |||
| 8 | 8 | MathMax, | |
| 9 | 9 | ObjectKeys, | |
| 10 | 10 | RegExp, | |
| 11 | + StringPrototypeLocaleCompare, | ||
| 12 | + StringPrototypeSlice, | ||
| 11 | 13 | StringPrototypeTrimLeft, | |
| 12 | 14 | StringPrototypeRepeat, | |
| 13 | 15 | StringPrototypeReplace, | |
@@ -110,12 +112,30 @@ function format( | |||
| 110 | 112 | let text = ''; | |
| 111 | 113 | let maxFirstColumnUsed = 0; | |
| 112 | 114 | ||
| 115 | + const sortedOptions = ArrayPrototypeSort( | ||
| 116 | + [...options.entries()], | ||
| 117 | + ({ 0: name1, 1: option1 }, { 0: name2, 1: option2 }) => { | ||
| 118 | + if (option1.defaultIsTrue) { | ||
| 119 | + name1 = `--no-${StringPrototypeSlice(name1, 2)}`; | ||
| 120 | + } | ||
| 121 | + if (option2.defaultIsTrue) { | ||
| 122 | + name2 = `--no-${StringPrototypeSlice(name2, 2)}`; | ||
| 123 | + } | ||
| 124 | + return StringPrototypeLocaleCompare(name1, name2); | ||
| 125 | + }, | ||
| 126 | + ); | ||
| 127 | + | ||
| 113 | 128 | for (const { | |
| 114 | - 0: name, 1: { helpText, type, value } | ||
| 115 | - } of ArrayPrototypeSort([...options.entries()])) { | ||
| 129 | + 0: name, 1: { helpText, type, value, defaultIsTrue } | ||
| 130 | + } of sortedOptions) { | ||
| 116 | 131 | if (!helpText) continue; | |
| 117 | 132 | ||
| 118 | 133 | let displayName = name; | |
| 134 | + | ||
| 135 | + if (defaultIsTrue) { | ||
| 136 | + displayName = `--no-${StringPrototypeSlice(displayName, 2)}`; | ||
| 137 | + } | ||
| 138 | + | ||
| 119 | 139 | const argDescription = getArgDescription(type); | |
| 120 | 140 | if (argDescription) | |
| 121 | 141 | displayName += `=${argDescription}`; | |
@@ -138,7 +158,7 @@ function format( | |||
| 138 | 158 | } | |
| 139 | 159 | ||
| 140 | 160 | let displayHelpText = helpText; | |
| 141 | - if (value === true) { | ||
| 161 | + if (value === !defaultIsTrue) { | ||
| 142 | 162 | // Mark boolean options we currently have enabled. | |
| 143 | 163 | // In particular, it indicates whether --use-openssl-ca | |
| 144 | 164 | // or --use-bundled-ca is the (current) default. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,8 +25,13 @@ function getAliasesFromBinding() { | |||
| 25 | 25 | return aliasesMap; | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | - function getOptionValue(option) { | ||
| 29 | - return getOptionsFromBinding().get(option)?.value; | ||
| 28 | + function getOptionValue(optionName) { | ||
| 29 | + const options = getOptionsFromBinding(); | ||
| 30 | + if (optionName.startsWith('--no-')) { | ||
| 31 | + const option = options.get('--' + optionName.slice(5)); | ||
| 32 | + return option && !option.value; | ||
| 33 | + } | ||
| 34 | + return options.get(optionName)?.value; | ||
| 30 | 35 | } | |
| 31 | 36 | ||
| 32 | 37 | function getAllowUnauthorized() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | 7 | const { | |
| 8 | 8 | ArrayIsArray, | |
| 9 | + ArrayPrototypePush, | ||
| 9 | 10 | BigUint64Array, | |
| 10 | 11 | Float64Array, | |
| 11 | 12 | NumberMAX_SAFE_INTEGER, | |
@@ -249,14 +250,19 @@ const trailingValuesRegex = /=.*$/; | |||
| 249 | 250 | // from data in the config binding. | |
| 250 | 251 | function buildAllowedFlags() { | |
| 251 | 252 | const { | |
| 252 | - envSettings: { kAllowedInEnvironment } | ||
| 253 | + envSettings: { kAllowedInEnvironment }, | ||
| 254 | + types: { kBoolean }, | ||
| 253 | 255 | } = internalBinding('options'); | |
| 254 | 256 | const { options, aliases } = require('internal/options'); | |
| 255 | 257 | ||
| 256 | 258 | const allowedNodeEnvironmentFlags = []; | |
| 257 | 259 | for (const [name, info] of options) { | |
| 258 | 260 | if (info.envVarSettings === kAllowedInEnvironment) { | |
| 259 | - allowedNodeEnvironmentFlags.push(name); | ||
| 261 | + ArrayPrototypePush(allowedNodeEnvironmentFlags, name); | ||
| 262 | + if (info.type === kBoolean) { | ||
| 263 | + const negatedName = `--no-${name.slice(2)}`; | ||
| 264 | + ArrayPrototypePush(allowedNodeEnvironmentFlags, negatedName); | ||
| 265 | + } | ||
| 260 | 266 | } | |
| 261 | 267 | } | |
| 262 | 268 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -425,7 +425,7 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 425 | 425 | // By default, always abort when --abort-on-uncaught-exception was passed. | |
| 426 | 426 | should_abort_on_uncaught_toggle_[0] = 1; | |
| 427 | 427 | ||
| 428 | - if (options_->no_force_async_hooks_checks) { | ||
| 428 | + if (!options_->force_async_hooks_checks) { | ||
| 429 | 429 | async_hooks_.no_force_checks(); | |
| 430 | 430 | } | |
| 431 | 431 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -207,6 +207,7 @@ constexpr size_t kFsStatsBufferLength = | |||
| 207 | 207 | V(crypto_rsa_pss_string, "rsa-pss") \ | |
| 208 | 208 | V(cwd_string, "cwd") \ | |
| 209 | 209 | V(data_string, "data") \ | |
| 210 | + V(default_is_true_string, "defaultIsTrue") \ | ||
| 210 | 211 | V(deserialize_info_string, "deserializeInfo") \ | |
| 211 | 212 | V(dest_string, "dest") \ | |
| 212 | 213 | V(destroyed_string, "destroyed") \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1082,9 +1082,9 @@ int Start(int argc, char** argv) { | |||
| 1082 | 1082 | const std::vector<size_t>* indexes = nullptr; | |
| 1083 | 1083 | std::vector<intptr_t> external_references; | |
| 1084 | 1084 | ||
| 1085 | - bool force_no_snapshot = | ||
| 1086 | - per_process::cli_options->per_isolate->no_node_snapshot; | ||
| 1087 | - if (!force_no_snapshot) { | ||
| 1085 | + bool use_no_snapshot = | ||
| 1086 | + per_process::cli_options->per_isolate->node_snapshot; | ||
| 1087 | + if (use_no_snapshot) { | ||
| 1088 | 1088 | v8::StartupData* blob = NodeMainInstance::GetEmbeddedSnapshotBlob(); | |
| 1089 | 1089 | if (blob != nullptr) { | |
| 1090 | 1090 | // TODO(joyeecheung): collect external references and set it in | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,12 +23,14 @@ template <typename Options> | |||
| 23 | 23 | void OptionsParser<Options>::AddOption(const char* name, | |
| 24 | 24 | const char* help_text, | |
| 25 | 25 | bool Options::* field, | |
| 26 | - OptionEnvvarSettings env_setting) { | ||
| 26 | + OptionEnvvarSettings env_setting, | ||
| 27 | + bool default_is_true) { | ||
| 27 | 28 | options_.emplace(name, | |
| 28 | 29 | OptionInfo{kBoolean, | |
| 29 | 30 | std::make_shared<SimpleOptionField<bool>>(field), | |
| 30 | 31 | env_setting, | |
| 31 | - help_text}); | ||
| 32 | + help_text, | ||
| 33 | + default_is_true}); | ||
| 32 | 34 | } | |
| 33 | 35 | ||
| 34 | 36 | template <typename Options> | |
@@ -186,7 +188,8 @@ auto OptionsParser<Options>::Convert( | |||
| 186 | 188 | return OptionInfo{original.type, | |
| 187 | 189 | Convert(original.field, get_child), | |
| 188 | 190 | original.env_setting, | |
| 189 | - original.help_text}; | ||
| 191 | + original.help_text, | ||
| 192 | + original.default_is_true}; | ||
| 190 | 193 | } | |
| 191 | 194 | ||
| 192 | 195 | template <typename Options> | |
@@ -225,6 +228,10 @@ inline std::string RequiresArgumentErr(const std::string& arg) { | |||
| 225 | 228 | return arg + " requires an argument"; | |
| 226 | 229 | } | |
| 227 | 230 | ||
| 231 | + inline std::string NegationImpliesBooleanError(const std::string& arg) { | ||
| 232 | + return arg + " is an invalid negation because it is not a boolean option"; | ||
| 233 | + } | ||
| 234 | + | ||
| 228 | 235 | // We store some of the basic information around a single Parse call inside | |
| 229 | 236 | // this struct, to separate storage of command line arguments and their | |
| 230 | 237 | // handling. In particular, this makes it easier to introduce 'synthetic' | |
@@ -325,6 +332,13 @@ void OptionsParser<Options>::Parse( | |||
| 325 | 332 | name[i] = '-'; | |
| 326 | 333 | } | |
| 327 | 334 | ||
| 335 | + // Convert --no-foo to --foo and keep in mind that we're negating. | ||
| 336 | + bool is_negation = false; | ||
| 337 | + if (name.find("--no-") == 0) { | ||
| 338 | + name.erase(2, 3); // remove no- | ||
| 339 | + is_negation = true; | ||
| 340 | + } | ||
| 341 | + | ||
| 328 | 342 | { | |
| 329 | 343 | auto it = aliases_.end(); | |
| 330 | 344 | // Expand aliases: | |
@@ -367,7 +381,12 @@ void OptionsParser<Options>::Parse( | |||
| 367 | 381 | } | |
| 368 | 382 | ||
| 369 | 383 | { | |
| 370 | - auto implications = implications_.equal_range(name); | ||
| 384 | + std::string implied_name = name; | ||
| 385 | + if (is_negation) { | ||
| 386 | + // Implications for negated options are defined with "--no-". | ||
| 387 | + implied_name.insert(2, "no-"); | ||
| 388 | + } | ||
| 389 | + auto implications = implications_.equal_range(implied_name); | ||
| 371 | 390 | for (auto it = implications.first; it != implications.second; ++it) { | |
| 372 | 391 | if (it->second.type == kV8Option) { | |
| 373 | 392 | v8_args->push_back(it->second.name); | |
@@ -384,6 +403,13 @@ void OptionsParser<Options>::Parse( | |||
| 384 | 403 | } | |
| 385 | 404 | ||
| 386 | 405 | const OptionInfo& info = it->second; | |
| 406 | + | ||
| 407 | + // Some V8 options can be negated and they are validated by V8 later. | ||
| 408 | + if (is_negation && info.type != kBoolean && info.type != kV8Option) { | ||
| 409 | + errors->push_back(NegationImpliesBooleanError(arg)); | ||
| 410 | + break; | ||
| 411 | + } | ||
| 412 | + | ||
| 387 | 413 | std::string value; | |
| 388 | 414 | if (info.type != kBoolean && info.type != kNoOp && info.type != kV8Option) { | |
| 389 | 415 | if (equals_index != std::string::npos) { | |
@@ -412,7 +438,7 @@ void OptionsParser<Options>::Parse( | |||
| 412 | 438 | ||
| 413 | 439 | switch (info.type) { | |
| 414 | 440 | case kBoolean: | |
| 415 | - *Lookup<bool>(info.field, options) = true; | ||
| 441 | + *Lookup<bool>(info.field, options) = !is_negation; | ||
| 416 | 442 | break; | |
| 417 | 443 | case kInteger: | |
| 418 | 444 | *Lookup<int64_t>(info.field, options) = std::atoll(value.c_str()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -377,18 +377,21 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | |||
| 377 | 377 | kAllowedInEnvironment); | |
| 378 | 378 | AddAlias("--es-module-specifier-resolution", | |
| 379 | 379 | "--experimental-specifier-resolution"); | |
| 380 | - AddOption("--no-deprecation", | ||
| 380 | + AddOption("--deprecation", | ||
| 381 | 381 | "silence deprecation warnings", | |
| 382 | - &EnvironmentOptions::no_deprecation, | ||
| 383 | - kAllowedInEnvironment); | ||
| 384 | - AddOption("--no-force-async-hooks-checks", | ||
| 382 | + &EnvironmentOptions::deprecation, | ||
| 383 | + kAllowedInEnvironment, | ||
| 384 | + true); | ||
| 385 | + AddOption("--force-async-hooks-checks", | ||
| 385 | 386 | "disable checks for async_hooks", | |
| 386 | - &EnvironmentOptions::no_force_async_hooks_checks, | ||
| 387 | - kAllowedInEnvironment); | ||
| 388 | - AddOption("--no-warnings", | ||
| 387 | + &EnvironmentOptions::force_async_hooks_checks, | ||
| 388 | + kAllowedInEnvironment, | ||
| 389 | + true); | ||
| 390 | + AddOption("--warnings", | ||
| 389 | 391 | "silence all process warnings", | |
| 390 | - &EnvironmentOptions::no_warnings, | ||
| 391 | - kAllowedInEnvironment); | ||
| 392 | + &EnvironmentOptions::warnings, | ||
| 393 | + kAllowedInEnvironment, | ||
| 394 | + true); | ||
| 392 | 395 | AddOption("--force-context-aware", | |
| 393 | 396 | "disable loading non-context-aware addons", | |
| 394 | 397 | &EnvironmentOptions::force_context_aware, | |
@@ -579,9 +582,9 @@ PerIsolateOptionsParser::PerIsolateOptionsParser( | |||
| 579 | 582 | "track heap object allocations for heap snapshots", | |
| 580 | 583 | &PerIsolateOptions::track_heap_objects, | |
| 581 | 584 | kAllowedInEnvironment); | |
| 582 | - AddOption("--no-node-snapshot", | ||
| 585 | + AddOption("--node-snapshot", | ||
| 583 | 586 | "", // It's a debug-only option. | |
| 584 | - &PerIsolateOptions::no_node_snapshot, | ||
| 587 | + &PerIsolateOptions::node_snapshot, | ||
| 585 | 588 | kAllowedInEnvironment); | |
| 586 | 589 | ||
| 587 | 590 | // Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS. | |
@@ -991,6 +994,10 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) { | |||
| 991 | 994 | env->type_string(), | |
| 992 | 995 | Integer::New(isolate, static_cast<int>(option_info.type))) | |
| 993 | 996 | .FromMaybe(false) || | |
| 997 | + !info->Set(context, | ||
| 998 | + env->default_is_true_string(), | ||
| 999 | + Boolean::New(isolate, option_info.default_is_true)) | ||
| 1000 | + .FromMaybe(false) || | ||
| 994 | 1001 | info->Set(context, env->value_string(), value).IsNothing() || | |
| 995 | 1002 | options->Set(context, name, info).IsEmpty()) { | |
| 996 | 1003 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,9 +120,9 @@ class EnvironmentOptions : public Options { | |||
| 120 | 120 | int64_t heap_snapshot_near_heap_limit = 0; | |
| 121 | 121 | std::string heap_snapshot_signal; | |
| 122 | 122 | uint64_t max_http_header_size = 16 * 1024; | |
| 123 | - bool no_deprecation = false; | ||
| 124 | - bool no_force_async_hooks_checks = false; | ||
| 125 | - bool no_warnings = false; | ||
| 123 | + bool deprecation = true; | ||
| 124 | + bool force_async_hooks_checks = true; | ||
| 125 | + bool warnings = true; | ||
| 126 | 126 | bool force_context_aware = false; | |
| 127 | 127 | bool pending_deprecation = false; | |
| 128 | 128 | bool preserve_symlinks = false; | |
@@ -194,7 +194,7 @@ class PerIsolateOptions : public Options { | |||
| 194 | 194 | public: | |
| 195 | 195 | std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() }; | |
| 196 | 196 | bool track_heap_objects = false; | |
| 197 | - bool no_node_snapshot = false; | ||
| 197 | + bool node_snapshot = true; | ||
| 198 | 198 | bool report_uncaught_exception = false; | |
| 199 | 199 | bool report_on_signal = false; | |
| 200 | 200 | bool experimental_top_level_await = true; | |
@@ -302,7 +302,8 @@ class OptionsParser { | |||
| 302 | 302 | void AddOption(const char* name, | |
| 303 | 303 | const char* help_text, | |
| 304 | 304 | bool Options::* field, | |
| 305 | - OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | ||
| 305 | + OptionEnvvarSettings env_setting = kDisallowedInEnvironment, | ||
| 306 | + bool default_is_true = false); | ||
| 306 | 307 | void AddOption(const char* name, | |
| 307 | 308 | const char* help_text, | |
| 308 | 309 | uint64_t Options::* field, | |
@@ -425,6 +426,7 @@ class OptionsParser { | |||
| 425 | 426 | std::shared_ptr<BaseOptionField> field; | |
| 426 | 427 | OptionEnvvarSettings env_setting; | |
| 427 | 428 | std::string help_text; | |
| 429 | + bool default_is_true = false; | ||
| 428 | 430 | }; | |
| 429 | 431 | ||
| 430 | 432 | // An implied option is composed of the information on where to store a | |
| Back | FazBrowse Home | New Git URL |
0 commit comments