( flags: CliFlags, data: unknown, renderHuman?: () => string | null | undefined, )
| 2 | import { printJson } from '../../utils/output.ts'; |
| 3 | |
| 4 | export function writeCommandOutput( |
| 5 | flags: CliFlags, |
| 6 | data: unknown, |
| 7 | renderHuman?: () => string | null | undefined, |
| 8 | ): void { |
| 9 | if (flags.json) { |
| 10 | printJson({ success: true, data }); |
| 11 | return; |
| 12 | } |
| 13 | const text = renderHuman?.(); |
| 14 | if (text) writeLine(text); |
| 15 | } |
| 16 | |
| 17 | function writeLine(text: string): void { |
| 18 | process.stdout.write(text.endsWith('\n') ? text : `${text}\n`); |
no test coverage detected