summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/node_options-inl.h19
-rw-r--r--src/node_options.cc12
2 files changed, 11 insertions, 20 deletions
diff --git a/src/node_options-inl.h b/src/node_options-inl.h
index 1d1eda5475..277121036e 100644
--- a/src/node_options-inl.h
+++ b/src/node_options-inl.h
@@ -307,6 +307,12 @@ void OptionsParser<Options>::Parse(
if (equals_index != std::string::npos)
original_name += '=';
+ // Normalize by replacing `_` with `-` in options.
+ for (std::string::size_type i = 2; i < name.size(); ++i) {
+ if (name[i] == '_')
+ name[i] = '-';
+ }
+
{
auto it = aliases_.end();
// Expand aliases:
@@ -341,19 +347,6 @@ void OptionsParser<Options>::Parse(
auto it = options_.find(name);
- if (it == options_.end()) {
- // We would assume that this is a V8 option if neither we nor any child
- // parser knows about it, so we convert - to _ for
- // canonicalization (since V8 accepts both) and look up again in order
- // to find a match.
- // TODO(addaleax): Make the canonicalization unconditional, i.e. allow
- // both - and _ in Node's own options as well.
- std::string::size_type index = 2; // Start after initial '--'.
- while ((index = name.find('-', index + 1)) != std::string::npos)
- name[index] = '_';
- it = options_.find(name);
- }
-
if ((it == options_.end() ||
it->second.env_setting == kDisallowedInEnvironment) &&
required_env_settings == kAllowedInEnvironment) {
diff --git a/src/node_options.cc b/src/node_options.cc
index 156ea11fe9..4951679994 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -102,8 +102,6 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
&EnvironmentOptions::experimental_worker,
kAllowedInEnvironment);
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
- // TODO(addaleax): Remove this when adding -/_ canonicalization to the parser.
- AddAlias("--expose_internals", "--expose-internals");
AddOption("--loader",
"(with --experimental-modules) use the specified file as a "
"custom loader",
@@ -204,15 +202,15 @@ PerIsolateOptionsParser::PerIsolateOptionsParser() {
kAllowedInEnvironment);
// Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS.
- AddOption("--abort_on_uncaught_exception",
+ AddOption("--abort-on-uncaught-exception",
"aborting instead of exiting causes a core file to be generated "
"for analysis",
V8Option{},
kAllowedInEnvironment);
- AddOption("--max_old_space_size", "", V8Option{}, kAllowedInEnvironment);
- AddOption("--perf_basic_prof", "", V8Option{}, kAllowedInEnvironment);
- AddOption("--perf_prof", "", V8Option{}, kAllowedInEnvironment);
- AddOption("--stack_trace_limit", "", V8Option{}, kAllowedInEnvironment);
+ AddOption("--max-old-space-size", "", V8Option{}, kAllowedInEnvironment);
+ AddOption("--perf-basic-prof", "", V8Option{}, kAllowedInEnvironment);
+ AddOption("--perf-prof", "", V8Option{}, kAllowedInEnvironment);
+ AddOption("--stack-trace-limit", "", V8Option{}, kAllowedInEnvironment);
Insert(&EnvironmentOptionsParser::instance,
&PerIsolateOptions::get_per_env_options);