-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process: generate list of allowed env flags programmatically #22638
Conversation
901d187
to
290af4b
Compare
lib/internal/bootstrap/node.js
Outdated
[...options].filter(([name, info]) => | ||
info.type === kV8Option && | ||
info.envVarSettings === kAllowedInEnvironment) | ||
.map(([name]) => name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to pass through filter options into getOptions
instead of doing the filtering here.
Since it has a string option at the moment, it would likely be best to accept an object for the options instead.
Another alternative to the current way would be to only iterate once over the entries (this is also nicer to read for me):
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);
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve gone with the second option for now, but yes, ultimately it might be better to do this in C++ land.
lib/internal/bootstrap/node.js
Outdated
for (const to of expansion) { | ||
if (!to.startsWith('-')) continue; | ||
if (aliases.get(to)) { | ||
expansion.push(...aliases.get(to)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: retrieving the value multiple times is not necessary.
290af4b
to
fa245b8
Compare
Avoids having a separate, second source of truth on this matter.
fa245b8
to
1f37916
Compare
New CI: https://ci.nodejs.org/job/node-test-pull-request/17028/ (:heavy_check_mark:) |
Avoids having a separate, second source of truth on this matter. PR-URL: #22638 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #22638 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This needs a backport PR to land on |
Avoids having a separate, second source of truth on this matter. PR-URL: #22638 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #22638 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Avoids having a separate, second source of truth on this matter.
The second diff is best viewed in whitespace-adjusted mode (append
?w=1
to GitHub URL).Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes