-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Also handle cloneProtoObject in mergeObject #45
Also handle cloneProtoObject in mergeObject #45
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`.
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 opening a PR! Can you please add a unit test?
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.
Added a test. Also fixed a bug :P
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 a nit
Co-authored-by: Matteo Collina <[email protected]> Signed-off-by: Segev Finer <[email protected]>
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
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.
index.js
Outdated
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])) |
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.
This is illegible. Could you refactor it into legible if
or switch
statements?
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.
Of course. Just tried to maintain the same illegible style that was used here beforehand hehe.
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.
Take a look now. Hopefully I got it right thanks to the tests. But it was truly a confusing piece of code.
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.
Yeah, I know you were just following what was laid down previously. Thank you for taking on the clean up.
This fixes not being able to set an instantiated logger in
options.logger
usingfastify-cli
, as it would try to merge a prototype object, thepino.Logger
.Checklist
npm run test
andnpm run benchmark
and the Code of conduct