Skip to content

Commit ba8411c

Browse files
committed
feat: return max mismatch to callback
1 parent 09df54e commit ba8411c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/wraith.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Wraith.prototype.compareScreenshots = function() {
240240
}
241241

242242
self.compareQueue = [];
243+
self.maxMismatch = 0;
243244

244245
for(var url in self.urls) {
245246
var dir = self.urls[url].substring(1).replace(/\/+$/,'') + '/';
@@ -278,6 +279,7 @@ Wraith.prototype.compareScreenshots = function() {
278279
async.eachLimit(self.compareQueue, self.maxConnections, function(task, callback) {
279280
resemble('./' + task.base).compareTo('./' + task.compare).ignoreAntialiasing().onComplete(function(data) {
280281
data.getDiffImage().pack().pipe(fs.createWriteStream(task.output));
282+
self.maxMismatch = data.misMatchPercentage > self.maxMismatch ? data.misMatchPercentage : self.maxMismatch;
281283
fs.writeFile('./' + task.diff, data.misMatchPercentage, function(err) {
282284
if(err) { log.error(err); }
283285
if(bar) {
@@ -298,7 +300,7 @@ Wraith.prototype.compareScreenshots = function() {
298300
self.generateGallery();
299301
} else {
300302
helpers.emptyFolder(self.outputFolder, function() {
301-
self.cb();
303+
self.cb(self.maxMismatch);
302304
});
303305
}
304306
return self;
@@ -314,6 +316,6 @@ Wraith.prototype.generateGallery = function() {
314316
self.outputFolder,
315317
self.config.project,
316318
self.server,
317-
self.cb
319+
function() { self.cb(self.maxMismatch); }
318320
);
319321
};

0 commit comments

Comments
 (0)