Skip to content

Commit

Permalink
fix(deps): pass along result for dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 28, 2017
1 parent 47ba43e commit 19832ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
30 changes: 16 additions & 14 deletions src/WorkerPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PoolWorker {
this.activeJobs -= 1;
this.onJobDone();
if (err) {
jobCallback(err instanceof Error ? err : new Error(err));
jobCallback(err instanceof Error ? err : new Error(err), arg);
} else {
jobCallback(null, arg);
}
Expand All @@ -114,22 +114,24 @@ class PoolWorker {
callback(eachErr);
return;
}
let bufferPosition = 0;
if (result.result) {
result.result = result.result.map((r) => {
if (r.buffer) {
const buffer = buffers[bufferPosition];
bufferPosition += 1;
if (r.string) {
return buffer.toString('utf-8');
}
return buffer;
}
return r.data;
});
}
if (error) {
callback(this.fromErrorObj(error));
callback(this.fromErrorObj(error), result);
return;
}
let bufferPosition = 0;
result.result = result.result.map((r) => {
if (r.buffer) {
const buffer = buffers[bufferPosition];
bufferPosition += 1;
if (r.string) {
return buffer.toString('utf-8');
}
return buffer;
}
return r.data;
});
callback(null, result);
});
break;
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ function pitch() {
resolve: this.resolve,
optionsContext: this.options.context,
}, (err, r) => {
if (r) {
r.fileDependencies.forEach(d => this.addDependency(d));
r.contextDependencies.forEach(d => this.addContextDependency(d));
}
if (err) {
callback(err);
return;
}
r.fileDependencies.forEach(d => this.addDependency(d));
r.contextDependencies.forEach(d => this.addContextDependency(d));
callback(null, ...r.result);
});
}
Expand Down

0 comments on commit 19832ec

Please sign in to comment.