git ssb

0+

cel / pull-git-remote-helper



Tree: 20c102b7036f7fee19f151e269d33cd7da837a3b

Files: 20c102b7036f7fee19f151e269d33cd7da837a3b / test / git-remote-empty.js

1214 bytesRaw
1#!/usr/bin/env node
2
3var toPull = require('stream-to-pull-stream')
4var pull = require('pull-stream')
5var util = require('../util')
6
7process.on('uncaughtException', function (err) {
8 if (err.stack)
9 err = {stack: err.stack, message: err.message}
10 process.send({error: err})
11 process.exit(1)
12})
13
14pull(
15 toPull(process.stdin),
16 require('../')({
17 prefix: 'foo',
18 objectSink: function (readObject) {
19 readObject(null, function next(end, type, length, read) {
20 if (end === true) return
21 if (end) throw end
22 var hasher = util.createGitObjectHash(type, length)
23 pull(
24 read,
25 hasher,
26 pull.collect(function (err, bufs) {
27 if (err) throw err
28 var buf = Buffer.concat(bufs)
29 process.send({object: {
30 type: type,
31 data: buf.toString('ascii'),
32 length: length,
33 hash: hasher.digest('hex')
34 }})
35 readObject(null, next)
36 })
37 )
38 })
39 },
40 refSink: pull.drain(function (ref) {
41 process.send({ref: ref})
42 })
43 }),
44 toPull(process.stdout, function (err) {
45 if (err)
46 throw err
47 process.disconnect()
48 })
49)
50

Built with git-ssb-web