mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-09-02 22:17:41 +00:00
feat: added script to automate language color retrieval (#1654)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
const fs = require('fs');
|
||||
const jsYaml = require('js-yaml');
|
||||
const axios = require('axios');
|
||||
|
||||
const LANGS_FILEPATH = "./src/common/languageColors.json"
|
||||
|
||||
//Retrieve languages from github linguist repository yaml file
|
||||
//@ts-ignore
|
||||
axios.get("https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml")
|
||||
.then((response) => {
|
||||
|
||||
//and convert them to a JS Object
|
||||
const languages = jsYaml.load(response.data);
|
||||
|
||||
const languageColors = {};
|
||||
|
||||
//Filter only language colors from the whole file
|
||||
Object.keys(languages).forEach((lang) => {
|
||||
languageColors[lang] = languages[lang].color;
|
||||
});
|
||||
|
||||
//Debug Print
|
||||
//console.dir(languageColors);
|
||||
fs.writeFileSync(LANGS_FILEPATH, JSON.stringify(languageColors, null, ' '));
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user