Skip to content

Commit

Permalink
Merge pull request #31 from jill64/dev
Browse files Browse the repository at this point in the history
Refactor actions.ts to handle errors and data for each app
  • Loading branch information
ghost-merge[bot] authored Nov 7, 2023
2 parents 891f0a7 + 1847f65 commit ad0073d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/ghost/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ export const actions = (
context: Omit<ActionContext, 'data'> & { data: WraithPayload | Error }
) =>
Promise.allSettled(
Object.entries(apps).map(
([name, app]) =>
Object.entries(apps).map(([name, app]) => {
const data =
context.data instanceof Error
? {
status: 'error' as const,
result: context.data
}
: context.data[name]

if (data) {
app.action?.({
...context,
data:
context.data instanceof Error
? {
status: 'error',
result: context.data
}
: context.data[name]
data
})
)
}
})
)

0 comments on commit ad0073d

Please sign in to comment.