seti.ts
898 B · typescript · 44 lines
1/* KINDS */23const KINDS: Record<string, string> = {4 ".gitignore": "git",5 ".prettierignore": "config",6 ".prettierrc": "json",7 ".python-version": "python",8 license: "license",9 astro: "html",10 c: "c",11 css: "css",12 csv: "csv",13 h: "h",14 html: "html",15 ico: "favicon",16 js: "js",17 json: "json",18 lock: "lock",19 md: "markdown",20 mjs: "js",21 png: "image",22 py: "python",23 rs: "rust",24 sh: "shell",25 svg: "svg",26 toml: "config",27 ts: "ts",28 tsx: "react",29 ttf: "font",30 wgsl: "cuda",31 woff: "font",32 woff2: "font",33};3435/* SETI */3637export function seti(path: string): string {38 const low = path.toLowerCase();39 const cut = low.lastIndexOf("/");40 const name = cut < 0 ? low : low.slice(cut + 1);41 const dot = name.lastIndexOf(".");42 const key = KINDS[name] ?? (dot > 0 ? KINDS[name.slice(dot + 1)] : undefined);43 return key === undefined ? "si" : `si si-${key}`;44}