avoid format changes in update-langs workflow (#81)
~~(I know the change in generate-langs-json.js isn't really necessary, but I think it still makes sense to have it.)~~
This commit is contained in:
@@ -2,30 +2,29 @@ import fs from "fs";
|
||||
|
||||
import axios from "axios";
|
||||
import { default as jsYaml } from "js-yaml";
|
||||
import * as prettier from "prettier";
|
||||
|
||||
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);
|
||||
// Retrieve languages from github linguist repository yaml file
|
||||
const response = await axios.get(
|
||||
"https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml",
|
||||
);
|
||||
|
||||
const languageColors = {};
|
||||
// and convert them to a JS Object
|
||||
const languages = jsYaml.load(response.data);
|
||||
|
||||
//Filter only language colors from the whole file
|
||||
Object.keys(languages).forEach((lang) => {
|
||||
languageColors[lang] = languages[lang].color;
|
||||
});
|
||||
const languageColors = {};
|
||||
|
||||
//Debug Print
|
||||
//console.dir(languageColors);
|
||||
fs.writeFileSync(
|
||||
LANGS_FILEPATH,
|
||||
JSON.stringify(languageColors, null, " "),
|
||||
);
|
||||
});
|
||||
// Filter only language colors from the whole file
|
||||
Object.keys(languages).forEach((lang) => {
|
||||
languageColors[lang] = languages[lang].color;
|
||||
});
|
||||
|
||||
// Debug Print
|
||||
// console.dir(languageColors);
|
||||
const jsonString = JSON.stringify(languageColors);
|
||||
fs.writeFileSync(
|
||||
LANGS_FILEPATH,
|
||||
await prettier.format(jsonString, { parser: "json" }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user