From 3b7f37363f19a46412b0fba969983db439ab69a7 Mon Sep 17 00:00:00 2001 From: GongXian Cao Date: Wed, 16 Aug 2017 13:10:17 +0800 Subject: [PATCH] fix When rendering a pass through a response, the callback never gets called on success: https://github.com/assaf/node-passbook/issues/12 --- lib/pass.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pass.js b/lib/pass.js index 3fefcfd..607cb90 100644 --- a/lib/pass.js +++ b/lib/pass.js @@ -257,17 +257,17 @@ Pass.prototype.pipe = function(output) { self.emit("error", lastError); } else { process.nextTick(function() { + zip.on("end", function() { + self.emit("end"); + }); + zip.on("error", function(error) { + self.emit("error", error); + }); self.signZip(zip, manifest, function(error) { if (error) { return self.emit("error", error); } zip.close(); - zip.on("end", function() { - self.emit("end"); - }); - zip.on("error", function(error) { - self.emit("error", error); - }); }); }); } @@ -342,6 +342,7 @@ Pass.prototype.signZip = function(zip, manifest, callback) { if (!error) { // Write signature file zip.addFile("signature").end(signature); + zip.emit("end"); } callback(error); });