(path: string)
| 43 | |
| 44 | /** File-type classification, not a claim that an embedded language was parsed. */ |
| 45 | export function sourceLanguage(path: string): string { |
| 46 | const name = pathKey(path).split('/').at(-1) ?? ''; |
| 47 | if (/^dockerfile(?:\.|$)/i.test(name)) return 'Dockerfile'; |
| 48 | if (/^(?:gnumakefile|makefile)(?:\.|$)/i.test(name)) return 'Makefile'; |
| 49 | if (name === 'CMakeLists.txt') return 'CMake'; |
| 50 | if (name.endsWith('.C')) return 'C++'; |
| 51 | return EXTENSIONS[name.split('.').at(-1)?.toLowerCase() ?? ''] ?? 'Unknown'; |
| 52 | } |
| 53 | export function languageColor(language: string): string { |
| 54 | if (COLORS[language]) return COLORS[language]; |
| 55 | // Stable for less common languages, independent of repository or row order. |
no test coverage detected