summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/node.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/bootstrap/node.js')
-rw-r--r--lib/internal/bootstrap/node.js45
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 284778becf..128725a532 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -671,9 +671,45 @@
const test = Function.call.bind(RegExp.prototype.test);
const {
- allowedV8EnvironmentFlags,
- allowedNodeEnvironmentFlags
- } = process.binding('config');
+ getOptions,
+ types: { kV8Option },
+ envSettings: { kAllowedInEnvironment }
+ } = internalBinding('options');
+ const { options, aliases } = getOptions();
+
+ const allowedV8EnvironmentFlags = [];
+ const allowedNodeEnvironmentFlags = [];
+ for (const [name, info] of options) {
+ if (info.envVarSettings === kAllowedInEnvironment) {
+ if (info.type === kV8Option) {
+ allowedV8EnvironmentFlags.push(name);
+ } else {
+ allowedNodeEnvironmentFlags.push(name);
+ }
+ }
+ }
+
+ for (const [ from, expansion ] of aliases) {
+ let isAccepted = true;
+ for (const to of expansion) {
+ if (!to.startsWith('-')) continue;
+ const recursiveExpansion = aliases.get(to);
+ if (recursiveExpansion) {
+ expansion.push(...recursiveExpansion);
+ continue;
+ }
+ isAccepted = options.get(to).envVarSettings === kAllowedInEnvironment;
+ if (!isAccepted) break;
+ }
+ if (isAccepted) {
+ let canonical = from;
+ if (canonical.endsWith('='))
+ canonical = canonical.substr(0, canonical.length - 1);
+ if (canonical.endsWith(' <arg>'))
+ canonical = canonical.substr(0, canonical.length - 4);
+ allowedNodeEnvironmentFlags.push(canonical);
+ }
+ }
const trimLeadingDashes = (flag) => replace(flag, leadingDashesRegex, '');
@@ -711,6 +747,9 @@
// permutations of a flag, including present/missing leading
// dash(es) and/or underscores-for-dashes in the case of V8-specific
// flags. Strips any values after `=`, inclusive.
+ // TODO(addaleax): It might be more flexible to run the option parser
+ // on a dummy option set and see whether it rejects the argument or
+ // not.
if (typeof key === 'string') {
key = replace(key, trailingValuesRegex, '');
if (test(leadingDashesRegex, key)) {