-
Notifications
You must be signed in to change notification settings - Fork 9
Fix merging of nested options objects from API #197
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
Conversation
…w nested opts to merge properly
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.
Thanks for taking the time to run this! Just thinking we might want to outsource the deep merge...
lib/config.js
Outdated
} | ||
|
||
return finalObject | ||
} |
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.
So something like _.merge might be a better approach here...
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 removed the custom functions and instead used _.merge
to merge the objects.
lib/config.js
Outdated
// merges API options into app.js options | ||
let allOpts = Object.assign(this.parseAppJs(opts), opts) | ||
let appJsOpts = this.parseAppJs(opts) | ||
let allOpts = merge(appJsOpts, opts) |
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.
any reason to separate out appJsOpts
to a variable here?
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.
There was when I was using the custom functions as it was a little easier to understand (and didn't mess about between contexts so much), but it may be better now to revert this line to have this.parseAppJs(opts)
inline.
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.
Ok let's swap that back, then looks good to merge!
🎉 |
Relates to static-dev/spike#38
Referenced PR exposed issue that nested options objects being passed from the API are not merged properly with options from
App.js
– BecauseObject.assign
copies the full reference over if the value of a key:value pair is an object. This was leading to server options set inApp.js
being ignored.This PR fixes this issue by changing the way options are merged to use a method suitable for nested objects.
There is a new test to check that the merge is operating properly.