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:
parent
1670397686
commit
87301c61a2
1 changed files with 0 additions and 45 deletions
45
repos.js
45
repos.js
|
@ -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");
|
||||
}
|
Loading…
Reference in a new issue