Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created February 27, 2022 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/8f7dcb1cb5f595b5c754b66c8423cbf8 to your computer and use it in GitHub Desktop.
Save brunosabot/8f7dcb1cb5f595b5c754b66c8423cbf8 to your computer and use it in GitHub Desktop.
const MAP_LANGUAGE = {
yml: "yaml",
Dockerfile: "docker",
eslintrc: "json",
js: "javascript",
ts: "typescript",
stylelintrc: "json",
prettierrc: "json",
};
function getLanguage(inputLanguage: string | undefined) {
if (inputLanguage === undefined) return "text";
if (inputLanguage in MAP_LANGUAGE) {
return MAP_LANGUAGE[inputLanguage as keyof typeof MAP_LANGUAGE];
}
return inputLanguage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment