Skip to content

Commit

Permalink
fix: do not use streams to avoid 'Stream not writable' error
Browse files Browse the repository at this point in the history
  • Loading branch information
j0tunn committed Apr 26, 2017
1 parent 4cbde93 commit d185422
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.gitignore
.jshintignore
.jshintrc
.npmignore
**/.*
test/
coverage/
10 changes: 5 additions & 5 deletions lib/png.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class PNGImage {
* @param {function} callback function
*/
exports.fromFile = (filePath, callback) => {
const png = new PNG();
fs.createReadStream(filePath)
.pipe(png)
.on('parsed', () => callback(null, new PNGImage(png)))
.on('error', callback);
fs.readFile(filePath, (error, data) => {
error
? callback(error, null)
: exports.fromBuffer(data, callback)
});
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"concat-stream": "^1.5.0",
"lodash": "^4.17.3",
"parse-color": "^1.0.0",
"pngjs": "^2.2.0"
"pngjs": "^3.0.1"
},
"devDependencies": {
"chai": "^1.9.1",
Expand Down

0 comments on commit d185422

Please sign in to comment.