(path: string)
| 213 | } |
| 214 | |
| 215 | export function languageFromPath(path: string): string { |
| 216 | const lower = path.toLowerCase() |
| 217 | const basename = lower.split(/[\\/]/).pop() ?? lower |
| 218 | |
| 219 | if (BASENAME_MAP[basename]) { |
| 220 | return BASENAME_MAP[basename] |
| 221 | } |
| 222 | |
| 223 | // Dockerfile.dev / Dockerfile.prod / Dockerfile.test — common multi-stage |
| 224 | // naming where the suffix is the build target rather than a file extension. |
| 225 | if (basename.startsWith("dockerfile.")) { |
| 226 | return "dockerfile" |
| 227 | } |
| 228 | |
| 229 | const dotIdx = basename.lastIndexOf(".") |
| 230 | if (dotIdx === -1 || dotIdx === basename.length - 1) { |
| 231 | return "plaintext" |
| 232 | } |
| 233 | const ext = basename.slice(dotIdx + 1) |
| 234 | return EXTENSION_MAP[ext] ?? "plaintext" |
| 235 | } |
no outgoing calls
no test coverage detected