(text: string, filename: string)
| 79 | return filePath; |
| 80 | } |
| 81 | async function copyOrWriteToFile(text: string, filename: string): Promise<string> { |
| 82 | const raw = await setClipboard(text); |
| 83 | if (raw) process.stdout.write(raw); |
| 84 | const lineCount = countCharInString(text, '\n') + 1; |
| 85 | const charCount = text.length; |
| 86 | // Also write to a temp file — clipboard paths are best-effort (OSC 52 needs |
| 87 | // terminal support), so the file provides a reliable fallback. |
| 88 | try { |
| 89 | const filePath = await writeToFile(text, filename); |
| 90 | return `Copied to clipboard (${charCount} characters, ${lineCount} lines)\nAlso written to ${filePath}`; |
| 91 | } catch { |
| 92 | return `Copied to clipboard (${charCount} characters, ${lineCount} lines)`; |
| 93 | } |
| 94 | } |
| 95 | function truncateLine(text: string, maxLen: number): string { |
| 96 | const firstLine = text.split('\n')[0] ?? ''; |
| 97 | if (stringWidth(firstLine) <= maxLen) { |
no test coverage detected