public
Created

Gist to download all your gists

  • Download Gist
download_gists.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
var request = require('request')
, path = require('path')
, fs = require('fs')
, url = "https://api.github.com/users/thomastraum/gists"
, savepath = './gists';
 
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
 
gists = JSON.parse( body );
gists.forEach( function(gist) {
console.log( "description: ", gist.description );
var dir = savepath + '/' + gist.description;
 
fs.mkdir( dir, function(err){
for(var file in gist.files){
 
var raw_url = gist.files[file].raw_url;
var filename = gist.files[file].filename;
 
console.log( "downloading... " + filename );
request(raw_url).pipe(fs.createWriteStream( dir + '/' + filename ));
}
});
});
 
}
 
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.