| 107 | } |
| 108 | |
| 109 | function detectLanguages(files: FileStat[]): Record<string, { files: number; lines: number }> { |
| 110 | const stats: Record<string, { files: number; lines: number }> = {}; |
| 111 | for (const f of files) { |
| 112 | const ext = path.extname(f.path).toLowerCase().slice(1); |
| 113 | if (!ext) continue; |
| 114 | const lang = LANG_BY_EXT[ext]; |
| 115 | if (!lang) continue; |
| 116 | if (!stats[lang]) stats[lang] = { files: 0, lines: 0 }; |
| 117 | stats[lang].files++; |
| 118 | stats[lang].lines += f.lines; |
| 119 | } |
| 120 | return stats; |
| 121 | } |
| 122 | |
| 123 | const LANG_BY_EXT: Record<string, string> = { |
| 124 | ts: 'TypeScript', tsx: 'TypeScript', js: 'JavaScript', jsx: 'JavaScript', |