Skip to content

Instantly share code, notes, and snippets.

@abdus
Created July 27, 2019 17:33
Show Gist options
  • Save abdus/ca347bef4dfce444177e655247cc52d9 to your computer and use it in GitHub Desktop.
Save abdus/ca347bef4dfce444177e655247cc52d9 to your computer and use it in GitHub Desktop.
const fetch = require('node-fetch')
const { execSync } = require('child_process')
async function getRepoURLs(user) {
let gh_data = await fetch(`https://api.github.com/users/${user}/repos`)
gh_data = await gh_data.json()
return gh_data
}
async function main() {
if (!process.argv[2])
throw new Error(`You must provide a valid Github username.`)
let repos = await getRepoURLs(process.argv[2])
for (let i of repos) {
const output = execSync(
`git clone ${i.html_url}.git ./output/${i.name}`
).toString()
console.log(output)
}
return
}
main().catch(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment