-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Split various utilities into standalone files #952
Conversation
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.
Looks good!
*/ | ||
'use strict'; | ||
|
||
const {listCompare} = require('./version.js'); |
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.
You can omit the .js
suffix in these require
s. There are a few in server.js
too.
downloadCount: downloadCountColor, | ||
floorCount: floorCountColor, | ||
version: versionColor, | ||
} = require('./lib/color-formatters.js'); |
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.
As you wrote, this seems like a good way to handle this, for the moment, to avoid conflicts. It'll be easy to change these names later.
* including colours based off download count, version number, etc. | ||
*/ | ||
'use strict'; | ||
|
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.
Did you make any changes in these implementations?
Thanks for the great explanation and the changes. Will leave this open a couple days in case @espadrine wants to comment. I'll be AFK this weekend BTW. ⛰ 🛶 🏕 |
Oh, I should have mentioned that I did not make any changes to the
implementations, they were simply cut and pasted. I wish Github showed that
lines of codes were moved or copied verbatim, like Phabricator dies.
I used the .js suffix for consistency, because the other requires are using
it.
Sent from my phone.
On Apr 20, 2017 6:24 AM, "Paul Melnikow" <[email protected]> wrote:
Thanks for the great explanation and the changes.
Will leave this open a couple days in case @espadrine
<https://github.com/espadrine> wants to comment.
I'll be AFK this weekend BTW. ⛰ 🛶 🏕
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#952 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFnHaIVpB8BXmx4Stzcwd0smnpN5q-nks5rx1yDgaJpZM4NCjeA>
.
|
Hehe, didn't realize that. When I see one, I wonder if something strange is going on with those files. We may as well stop, don't you think? |
The following utilities have been split into other files:
php-version.js
phpStableVersion
(renamed to "isStable")phpLatestVersion
(renamed to "latest")phpVersionCompare
(renamed to "compare")phpNumberedVersionData
(renamed to "numberedVersionData")omitv
asciiVersionCompare
version.js
latestVersion
(renamed to "latest")listCompare
latestDottedVersion
compareDottedVersions
color-formatters.js
:versionColor
(renamed to "version")floorCountColor
(renamed to "floorCount")downloadCountColor
(renamed to "downloadCount")coveragePercentageColor
(renamed to "coveragePercentage")text-formatters.js
starRating
currencyFromCode
ordinalNumber
metric
To avoid changing any of the code in
server.js
that uses these methods, I'm aliasing them when importing:(this syntax is object destructuring, added in Node.js 6.0.0)
This allows all code using
phpVersionCompare()
to continue to work with no changes and will avoid merge conflicts in the open pull requests.Ideally I would have done something like this:
and then changed
phpVersionCompare()
tophpVersion.compare()
, to keep everything namespaced(-ish).I confirmed that these changes worked on Node.js 6.4.0 by running the server and then loading
try.html
.There's a few badges that are broken that aren't due to this pull requests - For example the example badge for "Scrutinizer branch" shows "NaN%" 😛
References #948
cc @paulmelnikow