[Pkg-javascript-commits] [leaflet] 275/301: improve build reporting more

Jonas Smedegaard js at moszumanska.debian.org
Mon Jan 27 22:22:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet.

commit 16d12f4ac08379a769fd4cd17c19cc94ff333282
Author: Vladimir Agafonkin <agafonkin at gmail.com>
Date:   Thu Nov 28 15:20:25 2013 +0200

    improve build reporting more
---
 build/build.js | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/build/build.js b/build/build.js
index 518c93f..ad364fc 100644
--- a/build/build.js
+++ b/build/build.js
@@ -46,15 +46,20 @@ function getFiles(compsBase32) {
 
 exports.getFiles = getFiles;
 
-function getSizeDelta(newContent, oldContent) {
+function getSizeDelta(newContent, oldContent, fixCRLF) {
 	if (!oldContent) {
-		return 'new';
+		return ' (new)';
 	}
-	var newLen = newContent.replace(/\r\n?/g, '\n').length,
-		oldLen = oldContent.replace(/\r\n?/g, '\n').length,
-		delta = newLen - oldLen;
+	if (newContent === oldContent) {
+		return ' (unchanged)';
+	}
+	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) {
@@ -92,13 +97,11 @@ exports.build = function (callback, compsBase32, buildName) {
 	    srcPath = pathPart + '-src.js',
 
 	    oldSrc = loadSilently(srcPath),
-	    srcDelta = getSizeDelta(newSrc, oldSrc);
+	    srcDelta = getSizeDelta(newSrc, oldSrc, true);
 
 	console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
 
-	if (newSrc === oldSrc) {
-		// console.log('\tNo changes');
-	} else {
+	if (newSrc !== oldSrc) {
 		fs.writeFileSync(srcPath, newSrc);
 		console.log('\tSaved to ' + srcPath);
 	}
@@ -117,25 +120,21 @@ exports.build = function (callback, compsBase32, buildName) {
 	    gzippedDelta = '';
 
 	function done() {
-		var noChanges = newCompressed === oldCompressed;
-		if (!noChanges) {
+		if (newCompressed !== oldCompressed) {
 			fs.writeFileSync(path, newCompressed);
 			console.log('\tSaved to ' + path);
 		}
 		console.log('\tGzipped: ' + bytesToKB(newGzipped.length) + gzippedDelta);
-		if (noChanges) {
-			console.log('\tNo changes\n');
-		}
 		callback();
 	}
 
 	zlib.gzip(newCompressed, function (err, gzipped) {
 		if (err) { return; }
 		newGzipped = gzipped;
-		if (oldCompressed !== newCompressed) {
+		if (oldCompressed && (oldCompressed !== newCompressed)) {
 			zlib.gzip(oldCompressed, function (err, oldGzipped) {
 				if (err) { return; }
-				gzippedDelta = getSizeDelta(gzipped.toString(), oldGzipped.toString());
+				gzippedDelta = getSizeDelta(gzipped, oldGzipped);
 				done();
 			});
 		} else {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet.git



More information about the Pkg-javascript-commits mailing list