god-bless-your-code
Version:
Bless your code with ASCII gods, monsters, and mystical powers — your last line of defense against bugs and angry PMs.
26 lines (22 loc) • 459 B
text/typescript
import { extname } from 'node:path';
const htmlExtensions = new Set([
'.astro',
'.htm',
'.html',
'.marko',
'.svelte',
'.vue',
]);
const jsExtensions = new Set([
'.cjs',
'.css',
'.js',
'.mjs',
'.ts',
]);
export function detectCodeTypeByExt(id: string) {
const ext = extname(id).toLowerCase();
if (htmlExtensions.has(ext)) return 'html';
if (jsExtensions.has(ext)) return 'js';
return 'unknown';
}