1
0
Fork 0
mirror of https://github.com/dilllxd/gitfolio.git synced 2024-08-14 22:28:09 +00:00
gitfolio/repos.js
Josiah Bradbury ee230e3a1a Repos to pull from list like Blogs (#11)
* Reimplimented Repos pulling from list.

* added repos.json back in
2019-05-12 18:30:22 +05:30

45 lines
No EOL
1.2 KiB
JavaScript

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");
}