From 4e7d42d53b31d9b86ab1101638dda5b6e1bd7ebf Mon Sep 17 00:00:00 2001 From: Vladimir Polyakov Date: Sat, 21 Nov 2015 22:33:41 +0300 Subject: [PATCH] fix broken mocka output --- distributor.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/distributor.js b/distributor.js index 94ef325..97421db 100644 --- a/distributor.js +++ b/distributor.js @@ -94,7 +94,7 @@ exports.init = function(app, callback) { var buildLogLineNumbersHash = {}; distributor.on('buildData', function(build, data) { - var lines = data.trim().split('\n'), + var lines = _(data.split('\n')).chain().invoke('trim').compact().value(), logLineNumber = buildLogLineNumbersHash[build.id] || 0; lines = _(lines).map(function(line, index) { @@ -114,15 +114,17 @@ exports.init = function(app, callback) { line.buildId = build.id; }); // write build logs to db - db.logLines.put(lines, function(err) { - if (err) { - logger.error( - 'Error during write log line "' + logLineNumber + - '" for build "' + build.id + '":', - err.stack || err - ); - } - }); + if (lines.length) { + db.logLines.put(lines, function(err) { + if (err) { + logger.error( + 'Error during write log line "' + logLineNumber + + '" for build "' + build.id + '":', + err.stack || err + ); + } + }); + } }); callback(null, distributor);