Skip to content

Instantly share code, notes, and snippets.

@freddi301
Created June 28, 2016 10:38
Show Gist options
  • Save freddi301/6757bf3c9a12ebc3719c39ac56028986 to your computer and use it in GitHub Desktop.
Save freddi301/6757bf3c9a12ebc3719c39ac56028986 to your computer and use it in GitHub Desktop.
Clone Public gists
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