-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (33 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const fetch = require('node-fetch');
async function __getUserRepoNames(username){
let repoNames = [];
let repos = await fetch(`https://api.github.com/users/${username}/repos`);
repos = await repos.json();
for(let repo of repos){
repoNames.push(repo.name);
}
return repoNames;
}
async function __getRepoLanguages(username, repoName){
let languages = [];
let repoLangs = await fetch(`https://api.github.com/repos/${username}/${repoName}/languages`);
repoLangs = await repoLangs.json();
for(let lang in repoLangs){
languages.push(lang);
}
return languages;
}
async function main(username){
let repoNames = await __getUserRepoNames(username);
let languages = [];
for(let repoName of repoNames){
let repoLangs = await __getRepoLanguages(username, repoName);
for(let lang of repoLangs){
if(!languages.includes(lang)){
languages.push(lang);
}
}
}
return languages;
}
module.exports = main;