Skip to content

Commit

Permalink
Merge pull request #2679 from benlesh/tweak-size-reports
Browse files Browse the repository at this point in the history
chore(danger): tweak size reporting
  • Loading branch information
kwonoj committed Jun 19, 2017
2 parents 4694a27 + c1bd359 commit 53312d7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ var globalFile = 'Rx.js';
var minFile = 'Rx.min.js';

function sizeDiffBadge(name, value) {
return 'https://img.shields.io/badge/' + name + '-' + value + 'KB-red.svg?style=flat-square';
var color = 'lightgrey';
if (value > 0) {
color = 'red';
} else if (value < 0) {
color = 'lime';
}
return 'https://img.shields.io/badge/' + name + '-' + getKB(value) + 'KB-' + color + '.svg?style=flat-square';
}

//post size of build
Expand Down Expand Up @@ -108,10 +114,10 @@ schedule(new Promise(function (res) {
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', getKB(global.size) - getKB(bundleGlobal.size)) + '"/>';
sizeMessage += '<img src="' + sizeDiffBadge('Global(gzipped)', getKB(global_gzip) - getKB(bundle_global_gzip)) + '"/>';
sizeMessage += '<img src="' + sizeDiffBadge('Min', getKB(min.size) - getKB(bundleMin.size)) + '"/>';
sizeMessage += '<img src="' + sizeDiffBadge('Min (gzipped)', getKB(min_gzip) - getKB(bundle_min_gzip)) + '"/>';
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) + '"/>';
message(sizeMessage);

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

0 comments on commit 53312d7

Please sign in to comment.