Skip to content

Commit

Permalink
Resolve promise on close event
Browse files Browse the repository at this point in the history
Amend test to use promise (would fail without the fix)
  • Loading branch information
ZJONSSON committed Jun 17, 2019
1 parent f162a85 commit c04769d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Extract (opts) {

extract.promise = function() {
return new Promise(function(resolve, reject) {
extract.on('finish', resolve);
extract.on('close', resolve);
extract.on('error',reject);
});
};
Expand Down
4 changes: 2 additions & 2 deletions test/extract-finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("Only emit finish/close when extraction has completed", function (t) {

delayStream._flush = function(cb) {
filesDone += 1;
cb();
setTimeout(cb, 100);
delayStream.emit('close');
};

Expand All @@ -40,7 +40,7 @@ test("Only emit finish/close when extraction has completed", function (t) {
unzipExtractor.on('error', function(err) {
throw err;
});
unzipExtractor.on('close', function() {
unzipExtractor.promise().then(function() {
t.same(filesDone,2);
t.end();
});
Expand Down

0 comments on commit c04769d

Please sign in to comment.