Download src/utils/get-language-from-path.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 963 Bytes
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/utils/get-language-from-path.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/utils/get-language-from-path.ts
-
curl -L -o get-language-from-path.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/utils/get-language-from-path.ts
963 Bytes
| export const getLanguageFromPath = (path: string): string => { | |
| const extension = path.split(".").pop()?.toLowerCase(); | |
| switch (extension) { | |
| case "js": | |
| case "jsx": | |
| return "javascript"; | |
| case "ts": | |
| case "tsx": | |
| return "typescript"; | |
| case "py": | |
| return "python"; | |
| case "html": | |
| return "html"; | |
| case "css": | |
| return "css"; | |
| case "json": | |
| return "json"; | |
| case "md": | |
| return "markdown"; | |
| case "yml": | |
| case "yaml": | |
| return "yaml"; | |
| case "sh": | |
| case "bash": | |
| return "bash"; | |
| case "dockerfile": | |
| return "dockerfile"; | |
| case "rs": | |
| return "rust"; | |
| case "go": | |
| return "go"; | |
| case "java": | |
| return "java"; | |
| case "cpp": | |
| case "cc": | |
| case "cxx": | |
| return "cpp"; | |
| case "c": | |
| return "c"; | |
| case "rb": | |
| return "ruby"; | |
| case "php": | |
| return "php"; | |
| case "sql": | |
| return "sql"; | |
| default: | |
| return "text"; | |
| } | |
| }; | |