Skip to content

Commit

Permalink
Close #20 PR: remove the callback on stderr.on('data').
Browse files Browse the repository at this point in the history
  • Loading branch information
throrin19 authored and sindresorhus committed Feb 18, 2016
1 parent fe86948 commit 06d68c6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = function (opts) {

var args = ['-'];
var ret = [];
var err = '';
var len = 0;

if (opts.floyd && typeof opts.floyd === 'number') {
Expand Down Expand Up @@ -59,10 +60,7 @@ module.exports = function (opts) {

cp.stderr.setEncoding('utf8');
cp.stderr.on('data', function (data) {
var err = new Error(data);
err.fileName = file.path;
cb(err);
return;
err += data;
});

cp.stdout.on('data', function (data) {
Expand All @@ -76,7 +74,14 @@ module.exports = function (opts) {
return;
});

cp.on('close', function () {
cp.on('close', function (code) {
if (code) {
err = new Error(err);
err.fileName = file.path;
cb(err);
return;
}

if (len < file.contents.length) {
file.contents = Buffer.concat(ret, len);
}
Expand Down

0 comments on commit 06d68c6

Please sign in to comment.