From 631beec44fe77288e38e4b78dbdb2b845848523b Mon Sep 17 00:00:00 2001 From: Sascha Sambale Date: Fri, 27 Jun 2014 13:47:13 +0200 Subject: [PATCH] Extended Callback: Now the compare callback will also return the original as well as the compareTo filename so it can be used in the callback method in order to tell the user which files had problems or were not equal to each other. --- lib/compare.js | 4 ++-- lib/utils.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/compare.js b/lib/compare.js index 471f0b97..e70dc6d1 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -27,7 +27,7 @@ module.exports = exports = function (proto) { // compare binary for IM is `compare`, for GM it's `gm compare` var bin = isImageMagick ? '' : 'gm '; var execCmd = bin + 'compare -metric mse ' + orig + ' ' + compareTo; - var tolerance = 0.4 + var tolerance = 0.4; // outputting the diff image if (typeof options === 'object') { if (options.file) { @@ -88,7 +88,7 @@ module.exports = exports = function (proto) { } var equality = parseFloat(match[1]); - cb(null, equality <= tolerance, equality, stdout); + cb(null, equality <= tolerance, equality, stdout, utils.unescape(orig), utils.unescape(compareTo)); }); } diff --git a/lib/utils.js b/lib/utils.js index 3f67c4cb..a4d46586 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -9,7 +9,11 @@ exports.escape = function escape (arg) { return '"' + String(arg).trim().replace(/"/g, '\\"') + '"'; -} +}; + +exports.unescape = function escape (arg) { + return String(arg).trim().replace(/"/g, ""); +}; exports.argsToArray = function (args) { var arr = []; @@ -20,4 +24,4 @@ exports.argsToArray = function (args) { } return arr; -} \ No newline at end of file +}; \ No newline at end of file