Created
June 16, 2014 16:38
-
-
Save kaustavha/614d6cce6993d9a3abb4 to your computer and use it in GitHub Desktop.
Script to download all of a users/orgs public git repos
This file contains 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
### | |
# This is a script to clone all of a users repositories off of github | |
# You need the git cli installed and the node-github pkg (npm install github) | |
# CLI Usage Examples: | |
# coffee gitScraper.coffee user :username | |
# coffee gitScraper.coffee org :orgname | |
### | |
process = require 'process' | |
githubApi = require 'github' | |
{spawn} = require 'child_process' | |
git = new githubApi( | |
version: "3.0.0" | |
debug: true | |
protocol: 'https' | |
timeout: 5000 | |
) | |
gitScrapeUser = (username) -> | |
spawn 'mkdir', [username] | |
git.repos.getFromUser {user: username}, (err, res) -> | |
console.log(err) if err | |
res.forEach (repo) -> | |
repoUrl = "https://github.com/#{username}/#{repo.name}.git" | |
spawn 'git', ['clone', repoUrl], {cwd: username} | |
gitScrapeOrg = (orgname) -> | |
spawn 'mkdir', [orgname] | |
git.repos.getFromOrg {org: orgname}, (err ,res) -> | |
console.log(err) if err | |
res.forEach (repo) -> | |
repoUrl = "https://github.com/#{orgname}/#{repo.name}.git" | |
spawn 'git', ['clone', repoUrl], {cwd: orgname} | |
switch process.argv[2] | |
when 'user' then gitScrapeUser process.argv[3] | |
when 'org' then gitScrapeOrg process.argv[3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment