From 25c1584da1622c6100ad594a5a598a235d958085 Mon Sep 17 00:00:00 2001 From: Yury Oparin Date: Thu, 3 Jul 2014 21:12:35 +0400 Subject: [PATCH 1/2] Update crx.js --- src/crx.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/crx.js b/src/crx.js index b56bd6c..b7f32d2 100644 --- a/src/crx.js +++ b/src/crx.js @@ -121,9 +121,12 @@ module.exports = new function() { } archive.finalize() + + archive.on('readable', function() { + this.contents = !this.contents.length ? archive.read() : Buffer.concat([this.contents, archive.read()]) + }.bind(this)) - archive.on("finish",function() { - this.contents = archive.read() + archive.on('finish', function() { cb.call(this) }.bind(this)) @@ -183,4 +186,4 @@ module.exports = new function() { } return ChromeExtension -} \ No newline at end of file +} From 3570b6444d2bc0644030c466282c9248cc36d7c2 Mon Sep 17 00:00:00 2001 From: Yury Oparin Date: Thu, 3 Jul 2014 21:16:40 +0400 Subject: [PATCH 2/2] Fixing issue #18 https://github.com/jed/crx/issues/18 --- src/crx.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/crx.js b/src/crx.js index b7f32d2..5bfd2d9 100644 --- a/src/crx.js +++ b/src/crx.js @@ -122,6 +122,10 @@ module.exports = new function() { archive.finalize() + // Relates to the issue: "Event 'finished' no longer valid #18" + // https://github.com/jed/crx/issues/18 + // TODO: Buffer concat could be a problem when building a big extension. + // So ideally only the 'finish' callback must be used. archive.on('readable', function() { this.contents = !this.contents.length ? archive.read() : Buffer.concat([this.contents, archive.read()]) }.bind(this))