1 | import resolve from './ops'
|
2 | import { RunnerConfig, RenderedAction, ActionResult } from './types'
|
3 |
|
4 | const execute = async (
|
5 | renderedActions: RenderedAction[],
|
6 | args: any,
|
7 | config: RunnerConfig,
|
8 | ): Promise<ActionResult[]> => {
|
9 | const { logger } = config
|
10 | const messages = []
|
11 | const results = []
|
12 | for (const action of renderedActions) {
|
13 | const { message } = action.attributes
|
14 | if (message) {
|
15 | messages.push(message)
|
16 | }
|
17 | const ops = resolve(action.attributes)
|
18 | for (const op of ops) {
|
19 | results.push(await op(action, args, config))
|
20 | }
|
21 | }
|
22 | if (messages.length > 0) {
|
23 | logger.colorful(`${args.action}:\n${messages.join('\n')}`)
|
24 | }
|
25 |
|
26 | return results
|
27 | }
|
28 | module.exports = execute
|