Skip to content

Instantly share code, notes, and snippets.

@wopian
Created September 8, 2020 23:31
Show Gist options
  • Save wopian/8639e5d24119cbd99548b73c18321686 to your computer and use it in GitHub Desktop.
Save wopian/8639e5d24119cbd99548b73c18321686 to your computer and use it in GitHub Desktop.
Linguist Languages Without Colours
// node --experimental-json-modules linguist
// The JSON data is converted from the following YAML file:
// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
import languageDump from './languages.json'
const languages = []
const languagesWithoutColour = []
const caseInsensitiveSort = (a, b) => a.language.localeCompare(b.language)
// Object of Objects to Array of Objects
for(const language in languageDump) {
if(languageDump.hasOwnProperty(language)) {
const item = languageDump[language]
item.language = language
languages.push(item)
}
}
languages.forEach(language => {
if (!language.color) languagesWithoutColour.push(language)
})
languagesWithoutColour.sort(caseInsensitiveSort).forEach(({ language, group }) => {
const groupText = group ? ` (grouped in \`${group}\`)` : ``
console.log(`- [ ] ${language}${groupText}`)
})
console.log(`\n${languages.length - languagesWithoutColour.length} languages have a language`)
console.log(`${languagesWithoutColour.length} languages do not have a colour\n`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment