(line: string)
| 20 | } |
| 21 | |
| 22 | export function formatCliTextLine(line: string): string { |
| 23 | if (!shouldUseCliColor()) { |
| 24 | return line; |
| 25 | } |
| 26 | |
| 27 | if (/^\s*(?:.*:\s+)?(?:fatal )?error:\s/iu.test(line)) { |
| 28 | return colorRed(line); |
| 29 | } |
| 30 | |
| 31 | if (/^\s*⚠ /u.test(line)) { |
| 32 | return line.replace( |
| 33 | /^(\s*)(⚠ )/u, |
| 34 | (_m, indent: string, prefix: string) => `${indent}${colorYellow(prefix)}`, |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | if (/^\s*✗ /u.test(line)) { |
| 39 | return line.replace( |
| 40 | /^(\s*)(✗ )/u, |
| 41 | (_m, indent: string, prefix: string) => `${indent}${colorRed(prefix)}`, |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | if (/^❌ /u.test(line)) { |
| 46 | return line.replace(/^(❌ )/u, (_m, prefix: string) => colorRed(prefix)); |
| 47 | } |
| 48 | |
| 49 | return line; |
| 50 | } |
no test coverage detected