-
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
Migrating from process.binding('config') to getOptions() #23588
Conversation
lib/internal/bootstrap/node.js
Outdated
@@ -137,7 +137,7 @@ | |||
setupQueueMicrotask(); | |||
} | |||
|
|||
if (process.binding('config').experimentalWorker) { | |||
if (internalBinding('options').getOptions('--experimental-worker')) { |
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.
can you factor out the internalBinding
into a single call up top and also save the flag calls as variables to be used later?
something like
const { getOptions } = internalBinding('options');
const experimentalModules = getOptions('experimentalModules');
// ...
if (experimentalModules) {
// ...
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.
Yes I will do that.
But one question. There is already some similar code in place, like line 114:
const options = internalBinding('options');
if (options.getOptions('--help')) {
NativeModule.require('internal/print_help').print(process.stdout);
return;
}
Should I redo that part also and change code to use as mentioned:
const { getOptions } = internalBinding('options');
const experimentalModules = getOptions('experimentalModules');
// ...
if (experimentalModules) {
// ...
Thanks
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.
As mentioned in my previous comment, will code like this (replacing line 114) be Ok:
const { getOptions } = internalBinding('options');
const helpOption = getOptions('--help');
const completionBashOption = getOptions('--completion-bash');
const experimentalModulesOption = getOptions('--experimental-modules');
const experimentalVMModulesOption = getOptions('--experimental-vm-modules');
const experimentalWorkerOption = getOptions('--experimental-worker');
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.
@burgerboydaddy Yes, that definitely looks okay :)
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.
approving with @devsnek 's suggestion
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.
LGTM with @devsnek's suggestion.
678e0f4
to
7d85fb6
Compare
Added suggested changes to the code
Please review. |
lib/internal/bootstrap/node.js
Outdated
@@ -183,7 +188,7 @@ | |||
{ | |||
// Install legacy getters on the `util` binding for typechecking. | |||
// TODO(addaleax): Turn into a full runtime deprecation. | |||
const { pendingDeprecation } = process.binding('config'); | |||
const { pendingDeprecation } = internalBinding('options').getOptions(); |
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.
@burgerboydaddy I think something went wrong with this one?
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.
@addaleax initial request was to replace process.binding('config') to
internalBinding('options).getOptions(). Is there any reason why this line shouldn't be included?
If yes, I will restore this line to original one.
Please let me know what is your opinion.
thanks
Fixed issues.
|
@burgerboydaddy Something seems to be odd here … github says there are about 200 commits in this PR, some of which are merge commits? Do you think you could rebase this against |
@addaleax I'm even thinking to re-do complete request (new PR). Will that be better? |
@burgerboydaddy You can do that, but rebasing this one should be totally fine as well – whichever you prefer |
@addaleax This are command that I just executed:
During rebase got error:
I fixed issue with file that I changed (node.js). After that did:
But after rebase --continue received response:
What should I do? |
@burgerboydaddy That’s odd … it would typically mean that the changes from your commits have already happened upstream; but that’s clearly not the case, so I’m not sure what to do with that. |
Rebased, addressed merge conflict, force pushed. |
Resume Build: https://ci.nodejs.org/job/node-test-pull-request/18063/ |
Resume Build: https://ci.nodejs.org/job/node-test-pull-request/18080/ |
Just landed a PR to fix the unreliable test that failed last CI run... Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/18094/ |
PR-URL: nodejs#23588 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Landed in bb79e76. Thanks for the contribution! 🎉 (If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.) |
PR-URL: #23588 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
PR-URL: #23588 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
PR-URL: #23588 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
PR-URL: #23588 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Change inside /lib/internal/bootstrap/node.js code from
process.binding('config') to
internalBinding('options).getOptions()
Changes are done for options:
--experimental-modules
--experimental-vm-modules
--experimental-worker
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes