Last active
August 1, 2018 14:39
-
-
Save vvkpd/776b59360b4aba10565d323e14d39034 to your computer and use it in GitHub Desktop.
can clone all repo of particular github user by command line, just say `node cloneAllRepo.js <github user name>` and can clone particular repo of any user,just say :`node <github_user_name> <repo_name>`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require('child_process'); | |
const cloneAllRepoOf = function(user,repo){ | |
exec(`curl https://api.github.com/users/${user}/repos`, (err,stdout) =>{ | |
const content = JSON.parse(stdout); | |
if(!Array.isArray(content)){ | |
console.log(stdout) | |
return ; | |
} | |
if(repo){ | |
exec(`git clone https://github.com/${user}/${repo}.git`) | |
return; | |
} | |
let allReposName = content.map(repo => repo.name); | |
allReposName.map(repo => { | |
console.log(`clonning ${repo}`); | |
exec(`git clone https://github.com/${user}/${repo}.git`) | |
}) | |
}) | |
} | |
let user = process.argv[2]; | |
let repo = process.argv[3]; | |
cloneAllRepoOf(user,repo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment