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

A few straight refactors in badge-renderers #5716

Merged
merged 4 commits into from
Oct 17, 2020
Merged

Conversation

paulmelnikow
Copy link
Member

These are aimed at improving readability and a bit of DRY.

@paulmelnikow paulmelnikow added the npm-package Badge generation and badge templates label Oct 16, 2020
@shields-cd shields-cd temporarily deployed to shields-staging-pr-5716 October 16, 2020 00:38 Inactive
@shields-ci
Copy link

shields-ci commented Oct 16, 2020

Messages
📖 ✨ Thanks for your contribution to Shields, @paulmelnikow!

Generated by 🚫 dangerJS against 4334d13

Comment on lines -732 to -734
if (minify) {
return stripXmlWhitespace(badge)
}
Copy link
Member

Choose a reason for hiding this comment

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

Could this change potentially have any behavioral impacts? Or was minify always truthy for all badge styles previously?

Copy link
Member Author

@paulmelnikow paulmelnikow Oct 16, 2020

Choose a reason for hiding this comment

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

No, I don't see how it could. badge-renderers.js is only used in make-badge.js, and in the only spot where the function is invoked it gets minify: true.

Copy link
Member

Choose a reason for hiding this comment

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

If I ever have to read the SVG outputs by eye, I usually flip minify off. How do you normally deal with that?

There was also a point where we were using it to make the snapshot tests more readable #4459 (comment) but then we switched to minified snapshots later, although I notice you've taken another approach to that elsewhere which should be less sensitive to whitespace changes, so hopefully best of both worlds there.. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, interesting. My workflow for that hasn't been great. Usually I save out the svg's from the browser and then open them in VS Code and format them.

I'd be happy to add an env var that turns off the minification, if you think that would be useful.

The formatted snapshots seem to be super nice, though! I imagine that may end up being sufficient.

Copy link
Member

Choose a reason for hiding this comment

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

Nah. Thinking about it,

-  return stripXmlWhitespace(
+  return (

isn't exactly much more effort than

-    minify: true,
+    minify: false,

on the odd occasion we want that - Its not that common.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't make it down to make-badge.js last night, would've been good to do so beforehand as I would've seen minify was always true 😆

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-5716 October 16, 2020 04:16 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-5716 October 16, 2020 04:20 Inactive
Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

👍

@github-actions
Copy link
Contributor

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm-package Badge generation and badge templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants