Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

When writing the diff file, Niffy does not wait for stream to close #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function* diff(pathA, pathB, pathDiff) {

debug('finished diffing imgs %s', new Date());

writePNG(png, pathDiff);
yield thunkify(writePNG)(png, pathDiff);

debug('finished img diffing %s', new Date());

Expand Down Expand Up @@ -64,10 +64,13 @@ function readPNG(path, callback) {
* @param {String} path
*/

function writePNG(png, path) {
function writePNG(png, path, callback) {
png
.pack()
.pipe(fs.createWriteStream(path));
.pipe(fs.createWriteStream(path))
.on('close', function() {
callback(null, this);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"defaults": "^1.0.2",
"mkdirp": "^0.5.1",
"nightmare": "^2.0.3",
"pngjs": "^3.0.1",
"pngjs": "^3.3.1",
"sprintf-js": "^1.0.3",
"thunkify": "^2.1.2",
"vo": "^1.0.3"
Expand Down