Skip to content

Commit

Permalink
Extra guard against missing tempFile prop
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Oct 14, 2018
1 parent dad91e1 commit 526cb30
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/OptiPng.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ OptiPng.prototype.end = function end(chunk) {
}.bind(this));
this.readStream.once('end', function onReadStreamEnd() {
this.push(null); // null closes the stream
fs.unlink(this.tempFile, function onUnlink(err){
// not emitting this error since stream is done
if (err) {
console.error(err.stack);
}
});
this.tempFile = null;
if (this.tempFile) {
fs.unlink(this.tempFile, function onUnlink(err){
// not emitting this error since stream is done
if (err) {
console.error(err.stack);
}
});
this.tempFile = null;
}
}.bind(this));
}.bind(this);
};
Expand Down

0 comments on commit 526cb30

Please sign in to comment.