-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation.ts
46 lines (40 loc) · 971 Bytes
/
operation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Emoji } from './constants.js'
import { genericText } from './generic-text.js'
import type { Section } from './interfaces.js'
export interface Config {
title: string
successes: string[]
failures: string[]
warnings: string[]
}
export const operationText = ({
title,
successes,
failures,
warnings
}: Config) => {
const sections = [] as Section[]
if (successes.length > 0) {
sections.push({
title: `${successes.length} Successes`,
body: successes.map((s) => `${Emoji.Success} ${s}`).join('\n')
})
}
if (failures.length > 0) {
sections.push({
title: `${failures.length} Failures`,
body: failures.map((s) => `${Emoji.Failure} ${s}`).join('\n')
})
}
if (warnings.length > 0) {
sections.push({
title: `${warnings.length} Warnings`,
body: warnings.map((s) => `${Emoji.Warning} ${s}`).join('\n')
})
}
return genericText({
title,
description: '',
sections
})
}