* Create a plain-text progress callback for --verbose mode. * No animations, no ANSI tricks — just timestamped lines to stdout.
()
| 299 | * No animations, no ANSI tricks — just timestamped lines to stdout. |
| 300 | */ |
| 301 | function createVerboseProgress(): (progress: { phase: string; current: number; total: number; currentFile?: string }) => void { |
| 302 | let lastPhase = ''; |
| 303 | let lastPct = -1; |
| 304 | const startTime = Date.now(); |
| 305 | |
| 306 | return (progress) => { |
| 307 | const elapsed = ((Date.now() - startTime) / 1000).toFixed(1); |
| 308 | |
| 309 | if (progress.phase !== lastPhase) { |
| 310 | lastPhase = progress.phase; |
| 311 | lastPct = -1; |
| 312 | console.log(`[${elapsed}s] Phase: ${progress.phase}`); |
| 313 | } |
| 314 | |
| 315 | if (progress.total > 0) { |
| 316 | const pct = Math.floor((progress.current / progress.total) * 100); |
| 317 | // Log every 5% to keep output manageable |
| 318 | if (pct >= lastPct + 5 || progress.current === progress.total) { |
| 319 | lastPct = pct; |
| 320 | console.log(`[${elapsed}s] ${progress.current}/${progress.total} (${pct}%)${progress.currentFile ? ` ${getGlyphs().dash} ${progress.currentFile}` : ''}`); |
| 321 | } |
| 322 | } else if (progress.current > 0) { |
| 323 | // Scanning phase (no total yet) — log periodically |
| 324 | if (progress.current % 1000 === 0 || progress.current === 1) { |
| 325 | console.log(`[${elapsed}s] ${formatNumber(progress.current)} files found`); |
| 326 | } |
| 327 | } |
| 328 | }; |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Print success message |
no test coverage detected