Skip to content

Commit

Permalink
handle stream errors
Browse files Browse the repository at this point in the history
  • Loading branch information
neophob committed Oct 26, 2018
1 parent 311b0e1 commit 4c921ff
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,26 @@ Docker.prototype.buildImage = function(file, opts, callback) {
pack = tar.pack(file.context, {
entries: file.src
});
return build(pack.pipe(zlib.createGzip()));

if (callback === undefined) {
return new self.modem.Promise(function(resolve, reject) {
pack.on('error', function(error) {
return reject(error);
});
pack.on('end', function() {
return resolve(build(stream));
});
var stream = pack.pipe(zlib.createGzip());
});
} else {
pack.on('error', function(error) {
return callback(error);
});
pack.on('end', function() {
return build(stream);
});
var stream = pack.pipe(zlib.createGzip());
}
} else {
return build(file);
}
Expand Down

0 comments on commit 4c921ff

Please sign in to comment.