Skip to content

Commit

Permalink
chore(danger): fix badge url (#2682)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj authored and benlesh committed Jun 20, 2017
1 parent ab06db6 commit 0506ea0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ if (!messageConventionValid) {
}

function getKB(size) {
return (size / 1024).toFixed(2);
return (size / 1024).toFixed(1);
}

function getFormattedKB(size) {
if (size < 0) {
return '-' + size.toString();
} else if (size > 0) {
return '+' + size.toString();
}
return size.toString();
}

var globalFile = 'Rx.js';
Expand All @@ -83,7 +92,7 @@ function sizeDiffBadge(name, value) {
} else if (value < 0) {
color = 'green';
}
return 'https://img.shields.io/badge/' + name + '-' + getKB(value) + 'KB-' + color + '.svg?style=flat-square';
return 'https://img.shields.io/badge/' + name + '-' + getFormattedKB(getKB(value)) + 'KB-' + color + '.svg?style=flat-square';
}

//post size of build
Expand Down Expand Up @@ -113,11 +122,11 @@ schedule(new Promise(function (res) {
var bundleMin = fs.statSync(bundleMinFile);
var bundle_min_gzip = gzipSize.sync(fs.readFileSync(bundleMinFile, 'utf8'));

var sizeMessage = '<img src="https://img.shields.io/badge/Size%20Diff%20%28' + releaseVersion + '%29--lightgrey.svg?style=flat-square"/> ';
sizeMessage += '<img src="' + sizeDiffBadge('Global', global.size - bundleGlobal.size) + '"/>';
sizeMessage += '<img src="' + sizeDiffBadge('Global(gzipped)', global_gzip - bundle_global_gzip) + '"/>';
sizeMessage += '<img src="' + sizeDiffBadge('Min', min.size - bundleMin.size) + '"/>';
sizeMessage += '<img src="' + sizeDiffBadge('Min (gzipped)', min_gzip - bundle_min_gzip) + '"/>';
var sizeMessage = '<img src="https://img.shields.io/badge/Size%20Diff%20%28' + releaseVersion + '%29--lightgrey.svg?style=flat-square"/> ';
sizeMessage += '<img src="' + sizeDiffBadge('Global', global.size - bundleGlobal.size) + '"/> ';
sizeMessage += '<img src="' + sizeDiffBadge('Global(gzip)', global_gzip - bundle_global_gzip) + '"/> ';
sizeMessage += '<img src="' + sizeDiffBadge('Min', min.size - bundleMin.size) + '"/> ';
sizeMessage += '<img src="' + sizeDiffBadge('Min (gzip)', min_gzip - bundle_min_gzip) + '"/> ';
message(sizeMessage);

markdown('> CJS: **' + getKB(result) +
Expand Down

0 comments on commit 0506ea0

Please sign in to comment.