Skip to content

Commit

Permalink
Merge pull request #23 from Comcast/master
Browse files Browse the repository at this point in the history
Added a promise to writeImageToFile
  • Loading branch information
Steven Edouard authored Jul 24, 2017
2 parents 6eb6ce0 + c186e10 commit 87ca437
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,17 @@ class ChartjsNode {
writeImageToFile(imageType, filePath) {
return this.getImageBuffer(imageType)
.then(buffer => {
var out = fs.createWriteStream(filePath);
return out.write(buffer);
return new BbPromise((resolve,reject) => {
var out = fs.createWriteStream(filePath);
out.on('finish', () => {
return resolve();
});
out.on('error', () => {
return reject();
});
out.write(buffer);
out.end();
});
});
}
/**
Expand Down

0 comments on commit 87ca437

Please sign in to comment.