Skip to content

Instantly share code, notes, and snippets.

@heapwolf heapwolf/20.js
Created Aug 6, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.