git-download-archive

0.1.0 • Public • Published

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

Package Sidebar

Install

npm i git-download-archive

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • alessioalex