Files: c2f96fca4e0046fd6b5ee048898f8db2c2c1d247 / test / git-remote-empty.js
1300 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | var util = require('../util') |
6 | |
7 | process.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 | |
14 | pull( |
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 | console.error('obj', type, length, JSON.stringify(buf.toString('ascii'))) |
30 | process.send({object: { |
31 | type: type, |
32 | data: buf.toString('ascii'), |
33 | length: length, |
34 | hash: hasher.digest('hex') |
35 | }}) |
36 | readObject(null, next) |
37 | }) |
38 | ) |
39 | }) |
40 | }, |
41 | refSink: pull.drain(function (ref) { |
42 | process.send({ref: ref}) |
43 | }) |
44 | }), |
45 | toPull(process.stdout, function (err) { |
46 | if (err) |
47 | throw err |
48 | process.disconnect() |
49 | }) |
50 | ) |
51 |
Built with git-ssb-web