Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created August 6, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heapwolf/3276709 to your computer and use it in GitHub Desktop.
Save heapwolf/3276709 to your computer and use it in GitHub Desktop.
streams/unzip
var request = require('request');
var zlib = require('zlib');
var fs = require('fs');
var tar = require('tar');
var tarstream = request('https://github.com/dscape/p/tarball/master');
var filestream = fs.createWriteStream(__dirname + '/node_modules/p.tar.gz');
tarstream.on('end', function () { console.log("download done"); });
tarstream
.pipe(zlib.Gunzip())
.pipe(tar.Extract({ path: __dirname + '/node_modules/' }))
.on('entry', function(entry) {
if (entry.type === 'File') {
console.log('[unpack] `' + entry.path + '`');
}
})
.on('end', function () { console.log("unpack done"); });
tarstream.pipe(filestream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment