Also handle cloneProtoObject in mergeObject#45
Merged
Fdawgs merged 9 commits intofastify:masterfrom Dec 22, 2024
Merged
Conversation
This fixes not being able to set an instantiated logger in `options.logger` using `fastify-cli`, as it would try to merge a prototype object, the `pino.Logger`.
mcollina
requested changes
Dec 7, 2024
Member
mcollina
left a comment
There was a problem hiding this comment.
Thanks for opening a PR! Can you please add a unit test?
segevfiner
commented
Dec 7, 2024
Co-authored-by: Matteo Collina <matteo.collina@gmail.com> Signed-off-by: Segev Finer <segev208@gmail.com>
jsumners
reviewed
Dec 8, 2024
index.js
Outdated
Comment on lines
112
to
117
| isNotPrototypeKey(key = sourceKeys[i]) && | ||
| ( | ||
| key in target && (targetKeys.indexOf(key) !== -1 && (result[key] = _deepmerge(target[key], source[key])), true) || // eslint-disable-line no-mixed-operators | ||
| key in target && (targetKeys.indexOf(key) !== -1 && // eslint-disable-line no-mixed-operators | ||
| ((isMergeableObject(source[key]) && cloneProtoObject && Object.getPrototypeOf(source[key]) !== JSON_PROTO && (result[key] = cloneProtoObject(source[key]))) || | ||
| (result[key] = _deepmerge(target[key], source[key]))), true) || // eslint-disable-line no-mixed-operators | ||
| (result[key] = clone(source[key])) |
Member
There was a problem hiding this comment.
This is illegible. Could you refactor it into legible if or switch statements?
Contributor
Author
There was a problem hiding this comment.
Of course. Just tried to maintain the same illegible style that was used here beforehand hehe.
Contributor
Author
There was a problem hiding this comment.
Take a look now. Hopefully I got it right thanks to the tests. But it was truly a confusing piece of code.
Member
There was a problem hiding this comment.
Yeah, I know you were just following what was laid down previously. Thank you for taking on the clean up.
jsumners
approved these changes
Dec 9, 2024
Fdawgs
approved these changes
Dec 9, 2024
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes not being able to set an instantiated logger in
options.loggerusingfastify-cli, as it would try to merge a prototype object, thepino.Logger.Checklist
npm run testandnpm run benchmarkand the Code of conduct