| 27 | } |
| 28 | |
| 29 | function formatInput(result: FormattableResult & WithInput, options: FormatOptions = {}): string[] { |
| 30 | const { color: enabled = true, legacyOutput = false } = options; |
| 31 | const { errors = [], warnings = [], input = "" } = result; |
| 32 | |
| 33 | if (!input) { |
| 34 | return [""]; |
| 35 | } |
| 36 | |
| 37 | const sign = "⧗"; |
| 38 | const decoration = enabled ? pc.gray(sign) : sign; |
| 39 | |
| 40 | const decoratedInput = enabled ? pc.bold(input) : input; |
| 41 | const hasProblems = errors.length > 0 || warnings.length > 0; |
| 42 | |
| 43 | if (!(options.verbose || hasProblems)) { |
| 44 | return []; |
| 45 | } |
| 46 | |
| 47 | if (legacyOutput) { |
| 48 | // legacy: single line with 'input: ' prefix, no extra newlines or dashes |
| 49 | return [`${decoration} input: ${decoratedInput}`]; |
| 50 | } |
| 51 | |
| 52 | return [`${decoration} --- input ---\n${decoratedInput}`]; |
| 53 | } |
| 54 | |
| 55 | export function formatResult( |
| 56 | result: FormattableResult = {}, |