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.

master
Sascha Sambale 10 years ago
parent 02bef0d4ea
commit 631beec44f
  1. 4
      lib/compare.js
  2. 8
      lib/utils.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));
});
}

@ -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;
}
};
Loading…
Cancel
Save