Created
August 6, 2012 17:09
-
-
Save heapwolf/3276709 to your computer and use it in GitHub Desktop.
streams/unzip
This file contains 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
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