-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add helper script for sorting browser versions #1314
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.
const compatData = JSON.parse(data.toString()); | ||
|
||
const apiName = Object.keys(compatData.api); | ||
const methods = Object.keys(compatData.api[apiName]); |
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 means it only works for compat data in the api/
hierarchy, right?
@@ -0,0 +1,45 @@ | |||
/* eslint-env node */ |
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.
The filename sort-versions.js
does not imply that it "only" sorts compat data by version_added
.
|
||
const api = compatData.api[apiName]; | ||
|
||
methods.forEach(method => { |
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.
Nit: Actually these are features
, not necessarily only methods.
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.
Also you could replace the assignment to const methods
by Object.keys(api).forEach(feature => {
here.
Thanks for reviewing. I'm out camping now. I'll try to remember to update
the PR on Monday :)
Den fre 13 juli 2018 20:30Claas Augner <[email protected]> skrev:
***@***.**** requested changes on this pull request.
Looks good overall, though I would actually suggest to integrate this as a
check into the lint task, so that the check would fail, if there is an
unsorted list of versions.
[image: blind-review] <https://github.com/zombie/blind-reviews>
------------------------------
In helper-scripts/sort-versions.js
<#1314 (comment)>
:
> @@ -0,0 +1,45 @@
+/* eslint-env node */
+
+const fs = require('fs');
+
+const fileName = process.argv.slice(2)[0];
+
+console.log(`Sorting version arrays in ${fileName}`);
+
+const data = fs.readFileSync(fileName);
+const compatData = JSON.parse(data.toString());
+
+const apiName = Object.keys(compatData.api);
+const methods = Object.keys(compatData.api[apiName]);
This means it only works for compat data in the api/ hierarchy, right?
------------------------------
In helper-scripts/sort-versions.js
<#1314 (comment)>
:
> @@ -0,0 +1,45 @@
+/* eslint-env node */
The filename sort-versions.js does not imply that it "only" sorts compat
data by version_added.
------------------------------
In helper-scripts/sort-versions.js
<#1314 (comment)>
:
> +
+const fs = require('fs');
+
+const fileName = process.argv.slice(2)[0];
+
+console.log(`Sorting version arrays in ${fileName}`);
+
+const data = fs.readFileSync(fileName);
+const compatData = JSON.parse(data.toString());
+
+const apiName = Object.keys(compatData.api);
+const methods = Object.keys(compatData.api[apiName]);
+
+const api = compatData.api[apiName];
+
+methods.forEach(method => {
Nit: Actually these are features, not necessarily only methods.
------------------------------
In helper-scripts/sort-versions.js
<#1314 (comment)>
:
> +
+const fs = require('fs');
+
+const fileName = process.argv.slice(2)[0];
+
+console.log(`Sorting version arrays in ${fileName}`);
+
+const data = fs.readFileSync(fileName);
+const compatData = JSON.parse(data.toString());
+
+const apiName = Object.keys(compatData.api);
+const methods = Object.keys(compatData.api[apiName]);
+
+const api = compatData.api[apiName];
+
+methods.forEach(method => {
Also you could replace the assignment to const methods by Object.keys(api).forEach(feature
=> { here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1314 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA1jjyfmNcKJkdAydag0YWCf-eUoF0Xzks5uGOc0gaJpZM4SilTI>
.
--
Med vänlig hälsning,
Jeremy Karlsson
|
Making own PR for the helper script after this comment: #1122 (comment)
This add a script that sorts browser versions in reverse chronological for you, since it's a little bit annoying to keep that in mind yourself when making the JSON, and more so when having to change it later! :)
To be run like this;
npm run sort-versions api/URL.json