Skip to content

Commit

Permalink
fix: Correctly return error codes, by handling promise errors
Browse files Browse the repository at this point in the history
This reverts commit 77c11a8.
  • Loading branch information
danez committed Nov 13, 2019
1 parent 4f49f5c commit c40971d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/spire/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function spire({
const context = { argv, cli, cwd, env, logger };
const state = createState();
const core = createCore(context, state);
const running = [];
// Resolve and flattern config
let config;
try {
Expand Down Expand Up @@ -51,7 +52,9 @@ async function spire({
// Call the plugin command
try {
logger.debug('Running %s.run', plugin.name);
await plugin.run({ options, ...context });
const promise = plugin.run({ options, ...context });
running.push(promise);
await promise;
} catch (error) {
errors.push(error);
}
Expand All @@ -72,6 +75,8 @@ async function spire({
return 1;
}
}
// Wait for commands to finish
await Promise.all(running).catch(() => { /* ignore errors, we already handle them above */});
// Run teardown hooks
for (const plugin of config.plugins) {
if (plugin.teardown) {
Expand Down

0 comments on commit c40971d

Please sign in to comment.