ensure callback is only called once

master
Aaron Heckmann 12 years ago
parent 4b3c7eb92b
commit e8ecf9158b
  1. 16
      lib/command.js
  2. 2
      test/index.js

@ -188,7 +188,17 @@ module.exports = function (proto) {
err = new Error("gm().stream() or gm().write() with a non-readable " +
"stream. Pass \"{bufferStream: true}\" to identify() " +
"or getter (size, format, etc...)");
return callback.call(this, err);
return cb(this, err);
}
// handle streaming to gm errors when gm/imageMagick is not installed
proc.stdin.on('error', handlerr);
proc.stdout.on('error', handlerr);
function handlerr (err) {
if ('EPIPE' == err.code && 'write' == err.syscall) {
err.message = missingBinMsg(self) + err.message;
}
cb(this, err);
}
self.sourceStream.pipe(proc.stdin);
@ -229,11 +239,11 @@ module.exports = function (proto) {
err.code = code;
err.signal = signal;
};
callback.call(this, err, stdout, stderr, cmd);
cb(this, err, stdout, stderr, cmd);
stdout = stderr = onOut = onErr = onExit = null;
});
} else {
callback.call(this, null, proc.stdout, proc.stderr, cmd);
cb(this, null, proc.stdout, proc.stderr, cmd);
}
return this;

@ -29,7 +29,7 @@ function test (imagemagick) {
function finish (filename) {
return function (err) {
if (err) throw new Error(err);
if (err) throw err;
--pending;
process.stdout.write('\033[2K');

Loading…
Cancel
Save