mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2025-03-07 15:08:07 +08:00
31 lines
808 B
JavaScript
31 lines
808 B
JavaScript
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, " "),
|
|
);
|
|
});
|