npm-publish-split-stream
v1.0.1
Published
Splits an npm publish request using jsonstream and duplexify
Downloads
12
Readme
npm-publish-split-stream
Splits an npm publish request using jsonstream and duplexify.
Usage
var PublishSplitStream = require('npm-publish-split-stream');
var http = require('http');
var zlib = require('zlib');
var tar = require('tar');
var concat = require('concat-stream');
http.createServer(function (req, res) {
//
// Create a tar parser and listen for
// entries from it.
//
var parser = tar.Parse();
parser.on('entry', function (e) {
// read the entire entry and log the contents.
e.pipe(concat({ encoding: 'string' }, function (content) {
console.log(e.path, content)
}));
});
//
// Parse the tarball from our request and then
// process it.
//
req.pipe(new PublishSplitStream())
.pipe(zlib.Unzip())
.pipe(parser);
});