-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
fix(core): not working first plugin when icon option enabled #137
Conversation
Codecov Report
@@ Coverage Diff @@
## master #137 +/- ##
==========================================
- Coverage 88.75% 88.55% -0.21%
==========================================
Files 25 26 +1
Lines 418 428 +10
Branches 112 100 -12
==========================================
+ Hits 371 379 +8
- Misses 34 42 +8
+ Partials 13 7 -6
Continue to review full report at Codecov.
|
Ah nice, we bumped into the same problem today as well! Thanks for the PR, that should fix the problem yes 🙌 One minor suggestion maybe: how about extracting the "config merging" into a separate function and test that? Relying on an SVG snapshot to test merged configs is kind of not intuitive. I/we can also open up a new PR to improve the testing if we don't want to do that in this PR. |
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.
👌
packages/core/src/plugins/svgo.js
Outdated
|
||
|
||
function concatArrays(objValue, srcValue) { | ||
if (isArray(objValue)) { |
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.
Nitpick: can't we use Array.isArray
?
packages/core/src/plugins/svgo.js
Outdated
@@ -26,7 +36,7 @@ export default async (code, config = {}, state = {}) => { | |||
const filePath = state.filePath || process.cwd() | |||
const svgoRcConfig = await explorer.search(filePath) | |||
const svgo = new SVGO( | |||
merge(getBaseSvgoConfig(config), svgoRcConfig, config.svgoConfig), | |||
mergeWith(getBaseSvgoConfig(config), svgoRcConfig, config.svgoConfig, concatArrays), |
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.
Nitpick: like suggested, I would extract the "merging" into a separate function and test that in isolation to make sure the "merged" config is correct.
@emmenko thank you for comments! just make improvements on your suggestions! what about it? |
Cool, thanks! Much better now 👌 PS: can you run prettier on the changed/test files? The formatting looks weird. |
@emmenko sorry for formatting! done with prettier. |
Awesome thanks 🙏 ! |
Hello! Just got not working plugin when enable
icon
option.Problem:
not working config:
working config:
Solution: add lodash merge function for concat arrays instead merge them and add test for it.