|
1 | | -const fs = require('fs'); |
2 | | -const jsYaml = require('js-yaml'); |
3 | | -const axios = require('axios'); |
| 1 | +const fs = require("fs"); |
| 2 | +const jsYaml = require("js-yaml"); |
| 3 | +const axios = require("axios"); |
4 | 4 |
|
5 | | -const LANGS_FILEPATH = "./src/common/languageColors.json" |
| 5 | +const LANGS_FILEPATH = "./src/common/languageColors.json"; |
6 | 6 |
|
7 | 7 | //Retrieve languages from github linguist repository yaml file |
8 | 8 | //@ts-ignore |
9 | | -axios.get("https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml") |
10 | | -.then((response) => { |
| 9 | +axios |
| 10 | + .get( |
| 11 | + "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml", |
| 12 | + ) |
| 13 | + .then((response) => { |
| 14 | + //and convert them to a JS Object |
| 15 | + const languages = jsYaml.load(response.data); |
11 | 16 |
|
12 | | - //and convert them to a JS Object |
13 | | - const languages = jsYaml.load(response.data); |
| 17 | + const languageColors = {}; |
14 | 18 |
|
15 | | - const languageColors = {}; |
| 19 | + //Filter only language colors from the whole file |
| 20 | + Object.keys(languages).forEach((lang) => { |
| 21 | + languageColors[lang] = languages[lang].color; |
| 22 | + }); |
16 | 23 |
|
17 | | - //Filter only language colors from the whole file |
18 | | - Object.keys(languages).forEach((lang) => { |
19 | | - languageColors[lang] = languages[lang].color; |
| 24 | + //Debug Print |
| 25 | + //console.dir(languageColors); |
| 26 | + fs.writeFileSync( |
| 27 | + LANGS_FILEPATH, |
| 28 | + JSON.stringify(languageColors, null, " "), |
| 29 | + ); |
20 | 30 | }); |
21 | | - |
22 | | - //Debug Print |
23 | | - //console.dir(languageColors); |
24 | | - fs.writeFileSync(LANGS_FILEPATH, JSON.stringify(languageColors, null, ' ')); |
25 | | - |
26 | | -}); |
|
0 commit comments