git-spawned-stream
Create a readable stream from a spawned git process.
Last updated 8 years ago by alessioalex .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install git-spawned-stream 
SYNC missed versions from official npm registry.

git-spawned-stream

Create a readable stream from a spawned git process.

Usage

gitSpawnedStream(repoPath, spawnArguments, limitInBytes, gitBinary)

Arguments:

  • repoPath - the path to the repo, ex: /home/alex/node/.git (or the path to the git bare repo)
  • spawnArguments - the arguments that will be passed to the child_process.spawn function
  • limitInBytes - kill the process if it exceeds the imposed limit (sends more data than allowed)
  • gitBinary - path to the git binary to use (use the one in PATH by default)

Example:

var gitSpawnedStream = require('git-spawned-stream');
var path = require('path');
var repoPath = process.env.REPO || path.join(__dirname, '.git');
repoPath = path.resolve(repoPath);
var byteLimit = 5 * 1024 * 1024; // 5 Mb

// sort of a git log -n 2
var stream = gitSpawnedStream(repoPath, [
  'rev-list',
  '--max-count=2',
  '--header',
  'HEAD'
], byteLimit);

stream.on('data', function(data) {
  console.log('DATA', data.toString('utf8'));
}).on('error', function(err) {
  console.error('An error occurred:');
  console.error('-----------------\n');
  console.error(err.message);
  process.exit(1);
}).on('end', function(killed) {
  // when the stream is cut, killed === true
  console.log("\n±±±±±±±±±±±±±±±±±\nThat's all folks!");
});

License

MIT

Current Tags

  • 1.0.1                                ...           latest (6 years ago)

4 Versions

  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE