Open History to see the last commit
1export type SetupGroup =
2 | { kind: 'serial'; command: string }
3 | { kind: 'parallel'; commands: Array<string> }
4
5export interface SetupBuilder {
6 serial: (command: string) => void
7 parallel: (commands: Array<string>) => void
8}
9
10export type SetupInput = Array<string> | ((builder: SetupBuilder) => void)
11
12export function buildSetupPlan(
13 input: SetupInput | undefined,
14): Array<SetupGroup> {
15 if (input === undefined) return []
16 if (Array.isArray(input)) {
17 return input.map((command) => ({ kind: 'serial', command }))
18 }
19 const groups: Array<SetupGroup> = []
20 input({
21 serial: (command) => groups.push({ kind: 'serial', command }),
22 parallel: (commands) => groups.push({ kind: 'parallel', commands }),
23 })
24 return groups
25}