Skip to content

Commit fac1692

Browse files
authored
Merge pull request #24 from gemini-testing/fix/stream.error
fix: do not use streams to avoid 'Stream not writable' error
2 parents 4cbde93 + 715ec43 commit fac1692

3 files changed

Lines changed: 8 additions & 11 deletions

File tree

.npmignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
.gitignore
2-
.jshintignore
3-
.jshintrc
4-
.npmignore
1+
**/.*
52
test/
63
coverage/

lib/png.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ class PNGImage {
100100
* @param {function} callback function
101101
*/
102102
exports.fromFile = (filePath, callback) => {
103-
const png = new PNG();
104-
fs.createReadStream(filePath)
105-
.pipe(png)
106-
.on('parsed', () => callback(null, new PNGImage(png)))
107-
.on('error', callback);
103+
fs.readFile(filePath, (error, data) => {
104+
error
105+
? callback(error, null)
106+
: exports.fromBuffer(data, callback)
107+
});
108108
};
109109

110110
/**

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "looks-same",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"description": "Pure node.js library for comparing PNG-images, taking into account human color perception.",
55
"main": "index.js",
66
"directories": {
@@ -11,7 +11,7 @@
1111
"concat-stream": "^1.5.0",
1212
"lodash": "^4.17.3",
1313
"parse-color": "^1.0.0",
14-
"pngjs": "^2.2.0"
14+
"pngjs": "^3.0.1"
1515
},
1616
"devDependencies": {
1717
"chai": "^1.9.1",

0 commit comments

Comments
 (0)