1
0
Fork 0
mirror of https://github.com/dilllxd/gitfolio.git synced 2024-08-14 22:28:09 +00:00

changed repos to update

This commit is contained in:
imfunny 2019-05-12 19:16:12 +05:30 committed by GitHub
parent 1670397686
commit 87301c61a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,45 +0,0 @@
const program = require('commander');
const fs = require('fs');
const got = require('got');
options = {
resources: "usable"
};
program
.version('0.1.0')
.option('-n, --name [username]', 'get username')
.parse(process.argv);
function PopulateRepos(username){
var repoData = [];
(async () => {
try {
var repos = await got(`https://api.github.com/users/${username}/repos?sort=created`);
repos = JSON.parse(repos.body);
for(var i = 0;i < repos.length;i++){
if(repos[i].fork == false){
repoData.push({
"html_url": repos[i].html_url,
"name": repos[i].name,
"description": repos[i].description,
"language": repos[i].language,
"stargazers_count": repos[i].stargazers_count,
"forks_count" :repos[i].forks_count
});
}
}
fs.writeFile('./repos/repos.json', JSON.stringify(repoData), function(err){
if (err) throw err;
console.log('Repos Created Successfully in repos folder.');
});
} catch (error) {
console.log(error);
}
})();
}
if (program.name) {
PopulateRepos(('%s', program.name));
} else {
console.log("provide a name to scrape repos");
}