Skip to content

Commit

Permalink
Bugfix: in parallel oao bootstrap, recover original subpackage `pac…
Browse files Browse the repository at this point in the history
…kage.json` files always, even if one of the subpackages fails to install (#42).
  • Loading branch information
guigrpa committed Jun 15, 2017
1 parent a635351 commit c194783
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Bugfix: in parallel `oao bootstrap`, recover original subpackage `package.json` files always, even if one of the subpackages fails to install (#42).

## 0.8.3 (Jun. 15, 2017)

* Parallelize `oao bootstrap` -- **substantially improved performance** (#42).
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const run = async (opts: Options) => {
}
};
if (opts.parallel) {
await runInParallel(pkgNames, installer);
await runInParallel(pkgNames, installer, { waitForAllToResolve: true });
} else {
await runInSeries(pkgNames, installer);
}
Expand Down
17 changes: 15 additions & 2 deletions src/utils/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ const runInSeries = async (items, cb) => {
return out;
};

const runInParallel = async (items, cb) =>
Promise.all(items.map(cb));
const runInParallel = async (items, cb, { waitForAllToResolve } = {}) => {
const promises = items.map(cb);
try {
await Promise.all(promises);
} catch (err) {
if (waitForAllToResolve) {
for (let i = 0; i < promises.length; i++) {
try {
await promises[i];
} catch (err2) { /* ignore */ }
}
}
throw err;
}
};

export {
runInSeries, runInParallel,
Expand Down

0 comments on commit c194783

Please sign in to comment.