git-download-archive
v0.1.0
Published
Get a tar/zip archive stream from a git repository (at a certain commit).
Downloads
4
Maintainers
Readme
git-download-archive
Get a tar/zip archive stream from a git repository (at a certain commit).
Usage
// returns a stream
gitDownloadArchive(repoPath, options)
Options param defaults to:
{
rev : 'HEAD',
format : 'tar', // zip
prefix : 'repo/'
}
Example:
var streamGitArchive = require('git-download-archive');
var path = require('path');
var repoPath = path.resolve(process.env.REPO || (__dirname + '/.git'));
var fs = require('fs');
var os = require('os');
var outPath = os.tmpdir() + '/repo.tar';
var out = fs.createWriteStream(outPath);
streamGitArchive(repoPath).on('end', function() {
console.log('Done, checkout %s', outPath);
}).once('data', function() {
console.log('Began streaming to %s', outPath);
}).on('error', function(err) {
console.error(err.message);
process.exit(1);
}).pipe(out);
Tests
npm test
License
MIT