diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 4fdf0ba8764455..c5ec2609bcfa8b 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -5,6 +5,7 @@ // thread and the worker threads. const { + ArrayPrototypeEvery, ArrayPrototypeMap, ArrayPrototypePush, ArrayPrototypeSplice, @@ -258,27 +259,24 @@ function buildAllowedFlags() { const { options, aliases } = require('internal/options'); const allowedNodeEnvironmentFlags = []; - for (const [name, info] of options) { + for (const { 0: name, 1: info } of options) { if (info.envVarSettings === kAllowedInEnvironment) { ArrayPrototypePush(allowedNodeEnvironmentFlags, name); } } - for (const [ from, expansion ] of aliases) { - let isAccepted = true; - for (const to of expansion) { - if (!StringPrototypeStartsWith(to, '-') || to === '--') continue; - const recursiveExpansion = aliases.get(to); - if (recursiveExpansion) { - if (recursiveExpansion[0] === to) - ArrayPrototypeSplice(recursiveExpansion, 0, 1); - ArrayPrototypePush(expansion, ...recursiveExpansion); - continue; - } - isAccepted = options.get(to).envVarSettings === kAllowedInEnvironment; - if (!isAccepted) break; + function isAccepted(to) { + if (!StringPrototypeStartsWith(to, '-') || to === '--') return true; + const recursiveExpansion = aliases.get(to); + if (recursiveExpansion) { + if (recursiveExpansion[0] === to) + ArrayPrototypeSplice(recursiveExpansion, 0, 1); + return ArrayPrototypeEvery(recursiveExpansion, isAccepted); } - if (isAccepted) { + return options.get(to).envVarSettings === kAllowedInEnvironment; + } + for (const { 0: from, 1: expansion } of aliases) { + if (ArrayPrototypeEvery(expansion, isAccepted)) { let canonical = from; if (StringPrototypeEndsWith(canonical, '=')) canonical = StringPrototypeSlice(canonical, 0, canonical.length - 1);