Skip to content
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

Deep copy process.config, needs for NodeJS 19+ #160

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

panther7
Copy link

lib/configure.js Outdated
Comment on lines 118 to 119
var config = JSON.parse(JSON.stringify(process.config)) || {}
, defaults = config.target_defaults
Copy link
Member

@TheJaredWilcurt TheJaredWilcurt Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.parse(JSON.stringify(null)) becomes "null", which is not falsey, so the code no longer falls back to {}. Below should retain the original intent, while also covering your change.

Also added in a comment to explain the need to stringify/pars.

Suggested change
var config = JSON.parse(JSON.stringify(process.config)) || {}
, defaults = config.target_defaults
// In Node v19 process.config is now frozen, so we need to clone it here:
var config = JSON.parse(JSON.stringify(process.config || {}))
var defaults = config.target_defaults

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for repsonse, done.

Copy link
Member

@TheJaredWilcurt TheJaredWilcurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@TheJaredWilcurt TheJaredWilcurt merged commit 272bb74 into nwjs:node-gyp-3.6.2 Oct 24, 2023
@panther7 panther7 deleted the 159-fix branch October 24, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants