diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-06-13 13:46:35 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-06-21 21:18:20 +0300 |
commit | 1bbe66f432591aea83555d27dd76c55fea040a0d (patch) | |
tree | 112ae06f8c3c305341967af71acbeb82c1b0d02f /src/node_options.h | |
parent | 86d6d816fd41bb015488c8a0022cc9cf4d1a174b (diff) |
src: allow to negate boolean CLI flags
This change allows all boolean flags to be negated using the `--no-`
prefix.
Flags that are `true` by default (for example `--deprecation`) are
still documented as negations.
With this change, it becomes possible to easily flip the default
value of a boolean flag and to override the value of a flag passed
in the NODE_OPTIONS environment variable.
`process.allowedNodeEnvironmentFlags` contains both the negated and
non-negated versions of boolean flags.
Co-authored-by: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/39023
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/node_options.h')
-rw-r--r-- | src/node_options.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/node_options.h b/src/node_options.h index a91dbd25978..d737c4f55ae 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -119,9 +119,9 @@ class EnvironmentOptions : public Options { int64_t heap_snapshot_near_heap_limit = 0; std::string heap_snapshot_signal; uint64_t max_http_header_size = 16 * 1024; - bool no_deprecation = false; - bool no_force_async_hooks_checks = false; - bool no_warnings = false; + bool deprecation = true; + bool force_async_hooks_checks = true; + bool warnings = true; bool force_context_aware = false; bool pending_deprecation = false; bool preserve_symlinks = false; @@ -193,7 +193,7 @@ class PerIsolateOptions : public Options { public: std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() }; bool track_heap_objects = false; - bool no_node_snapshot = false; + bool node_snapshot = true; bool report_uncaught_exception = false; bool report_on_signal = false; bool experimental_top_level_await = true; @@ -301,7 +301,8 @@ class OptionsParser { void AddOption(const char* name, const char* help_text, bool Options::* field, - OptionEnvvarSettings env_setting = kDisallowedInEnvironment); + OptionEnvvarSettings env_setting = kDisallowedInEnvironment, + bool default_is_true = false); void AddOption(const char* name, const char* help_text, uint64_t Options::* field, @@ -424,6 +425,7 @@ class OptionsParser { std::shared_ptr<BaseOptionField> field; OptionEnvvarSettings env_setting; std::string help_text; + bool default_is_true = false; }; // An implied option is composed of the information on where to store a |