Created
June 28, 2016 10:38
-
-
Save freddi301/6757bf3c9a12ebc3719c39ac56028986 to your computer and use it in GitHub Desktop.
Clone Public gists
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 gistUser = process.argv[2]; if (!gistUser) { | |
console.error('no gist user specified'); process.exit(1); } | |
const destDir = process.argv[3] || './'; | |
const exec = require('child_process').exec; | |
const path = require('path'); | |
exec(`curl -s https://api.github.com/users/${gistUser}/gists`, (e, so, se) => { | |
gists = JSON.parse(so).map(gist => ({ | |
folder: gist.description || gist.id, | |
pull: gist.git_pull_url })); | |
console.log(`These public gists will be cloned in ${destDir}`); | |
gists.forEach(gist => console.log(gist.folder)); | |
gists.forEach(gist => exec(`git clone ${gist.pull} "${path.join(destDir, gist.folder)}"`)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment