improve build reporting more
This commit is contained in:
parent
941b206714
commit
16d12f4ac0
@ -46,15 +46,20 @@ function getFiles(compsBase32) {
|
|||||||
|
|
||||||
exports.getFiles = getFiles;
|
exports.getFiles = getFiles;
|
||||||
|
|
||||||
function getSizeDelta(newContent, oldContent) {
|
function getSizeDelta(newContent, oldContent, fixCRLF) {
|
||||||
if (!oldContent) {
|
if (!oldContent) {
|
||||||
return 'new';
|
return ' (new)';
|
||||||
}
|
}
|
||||||
var newLen = newContent.replace(/\r\n?/g, '\n').length,
|
if (newContent === oldContent) {
|
||||||
oldLen = oldContent.replace(/\r\n?/g, '\n').length,
|
return ' (unchanged)';
|
||||||
delta = newLen - oldLen;
|
}
|
||||||
|
if (fixCRLF) {
|
||||||
|
newContent = newContent.replace(/\r\n?/g, '\n');
|
||||||
|
oldContent = oldContent.replace(/\r\n?/g, '\n');
|
||||||
|
}
|
||||||
|
var delta = newContent.length - oldContent.length;
|
||||||
|
|
||||||
return delta === 0 ? '' : '(' + (delta > 0 ? '+' : '') + delta + ' bytes)';
|
return delta === 0 ? '' : ' (' + (delta > 0 ? '+' : '') + delta + ' bytes)';
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSilently(path) {
|
function loadSilently(path) {
|
||||||
@ -92,13 +97,11 @@ exports.build = function (callback, compsBase32, buildName) {
|
|||||||
srcPath = pathPart + '-src.js',
|
srcPath = pathPart + '-src.js',
|
||||||
|
|
||||||
oldSrc = loadSilently(srcPath),
|
oldSrc = loadSilently(srcPath),
|
||||||
srcDelta = getSizeDelta(newSrc, oldSrc);
|
srcDelta = getSizeDelta(newSrc, oldSrc, true);
|
||||||
|
|
||||||
console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
|
console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
|
||||||
|
|
||||||
if (newSrc === oldSrc) {
|
if (newSrc !== oldSrc) {
|
||||||
// console.log('\tNo changes');
|
|
||||||
} else {
|
|
||||||
fs.writeFileSync(srcPath, newSrc);
|
fs.writeFileSync(srcPath, newSrc);
|
||||||
console.log('\tSaved to ' + srcPath);
|
console.log('\tSaved to ' + srcPath);
|
||||||
}
|
}
|
||||||
@ -117,25 +120,21 @@ exports.build = function (callback, compsBase32, buildName) {
|
|||||||
gzippedDelta = '';
|
gzippedDelta = '';
|
||||||
|
|
||||||
function done() {
|
function done() {
|
||||||
var noChanges = newCompressed === oldCompressed;
|
if (newCompressed !== oldCompressed) {
|
||||||
if (!noChanges) {
|
|
||||||
fs.writeFileSync(path, newCompressed);
|
fs.writeFileSync(path, newCompressed);
|
||||||
console.log('\tSaved to ' + path);
|
console.log('\tSaved to ' + path);
|
||||||
}
|
}
|
||||||
console.log('\tGzipped: ' + bytesToKB(newGzipped.length) + gzippedDelta);
|
console.log('\tGzipped: ' + bytesToKB(newGzipped.length) + gzippedDelta);
|
||||||
if (noChanges) {
|
|
||||||
console.log('\tNo changes\n');
|
|
||||||
}
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
zlib.gzip(newCompressed, function (err, gzipped) {
|
zlib.gzip(newCompressed, function (err, gzipped) {
|
||||||
if (err) { return; }
|
if (err) { return; }
|
||||||
newGzipped = gzipped;
|
newGzipped = gzipped;
|
||||||
if (oldCompressed !== newCompressed) {
|
if (oldCompressed && (oldCompressed !== newCompressed)) {
|
||||||
zlib.gzip(oldCompressed, function (err, oldGzipped) {
|
zlib.gzip(oldCompressed, function (err, oldGzipped) {
|
||||||
if (err) { return; }
|
if (err) { return; }
|
||||||
gzippedDelta = getSizeDelta(gzipped.toString(), oldGzipped.toString());
|
gzippedDelta = getSizeDelta(gzipped, oldGzipped);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user