Skip to content

Commit

Permalink
Build: Fix issue wrapping errors
Browse files Browse the repository at this point in the history
  • Loading branch information
molant committed Sep 24, 2019
1 parent 9f13687 commit 99d3a2b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions release/lib/utils.ts
Expand Up @@ -137,13 +137,24 @@ export const execa = (command: string, options?: execasync.Options) => {
type CustomTask = (ctx: any, task: ListrTaskWrapper) => Promise<any> | any;

export const taskErrorWrapper = (f: CustomTask) => {
return async (ctx: Context, task: ListrTaskWrapper) => {
return (ctx: Context, task: ListrTaskWrapper) => {
let result: any;

try {
await f(ctx, task);
} catch (err) {
ctx.error = err;
throw err;
result = f(ctx, task);
} catch (error) {
ctx.error = error;

throw error;
}

if (result && result.then) {
result.catch((error: Error) => {
ctx.error = error;
});
}

return result;
};
};

Expand Down

0 comments on commit 99d3a2b

Please sign in to comment.