Skip to content

Commit

Permalink
take into account core-js-bundle in downloads-by-versions script
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Feb 11, 2022
1 parent 4c4655d commit e507298
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions scripts/downloads-by-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ async function getStat(pkg) {
}

const { cyan, green } = chalk;
const PURE = !argv['main-only'];
const ALL = !argv['main-only'];
const core = await getStat('core-js');
const pure = PURE && await getStat('core-js-pure');
const pure = ALL && await getStat('core-js-pure');
const bundle = ALL && await getStat('core-js-bundle');
const downloadsByPatch = {};
const downloadsByMinor = {};
const downloadsByMajor = {};
let total = 0;

for (const [patch, downloadsMain] of Object.entries(core)) {
const downloadsPure = PURE && pure[patch] || 0;
for (let [patch, downloads] of Object.entries(core)) {
const semver = coerce(patch);
const { major } = semver;
const minor = `${ major }.${ semver.minor }`;
downloadsByPatch[patch] = downloadsMain + downloadsPure;
downloadsByMinor[minor] = (downloadsByMinor[minor] || 0) + downloadsMain + downloadsPure;
downloadsByMajor[major] = (downloadsByMajor[major] || 0) + downloadsMain + downloadsPure;
total += downloadsMain + downloadsPure;
if (ALL) downloads += (pure[patch] || 0) + (bundle[patch] || 0);
downloadsByPatch[patch] = downloads;
downloadsByMinor[minor] = (downloadsByMinor[minor] || 0) + downloads;
downloadsByMajor[major] = (downloadsByMajor[major] || 0) + downloads;
total += downloads;
}

function log(kind, map) {
Expand Down

0 comments on commit e507298

Please sign in to comment.