Files: cfeb530e50e371d1f66077bccf8a22e8e15f6427 / test / git-remote-test.js
987 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | |
6 | process.on('uncaughtException', function (err) { |
7 | if (err.stack) |
8 | err = {stack: err.stack, message: err.message} |
9 | process.send({error: err}) |
10 | process.exit(1) |
11 | }) |
12 | |
13 | pull( |
14 | toPull(process.stdin), |
15 | require('../')({ |
16 | prefix: 'foo', |
17 | objectSink: function (readObject) { |
18 | readObject(null, function next(end, type, read) { |
19 | if (end === true) return |
20 | if (end) throw end |
21 | pull( |
22 | read, |
23 | pull.collect(function (err, bufs) { |
24 | if (err) throw err |
25 | var data = Buffer.concat(bufs).toString('ascii') |
26 | process.send({object: {type: type, data: data}}) |
27 | readObject(null, next) |
28 | }) |
29 | ) |
30 | }) |
31 | }, |
32 | refSink: pull.drain(function (ref) { |
33 | process.send({ref: ref}) |
34 | }), |
35 | }), |
36 | toPull(process.stdout, function (err) { |
37 | if (err) |
38 | throw err |
39 | process.disconnect() |
40 | }) |
41 | ) |
42 |
Built with git-ssb-web