Files: b057fe40960502a3d16c60aef0f67bf2078455fe / test / remote / git-remote-empty.js
1237 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | var util = require('../../lib/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 | objectSink: function (read) { |
18 | read(null, function next(end, object) { |
19 | if (end === true) return |
20 | if (end) throw end |
21 | var hasher = util.createGitObjectHash(object.type, object.length) |
22 | pull( |
23 | object.read, |
24 | hasher, |
25 | pull.collect(function (err, bufs) { |
26 | if (err) throw err |
27 | var buf = Buffer.concat(bufs, object.length) |
28 | process.send({object: { |
29 | type: object.type, |
30 | data: buf.toString('ascii'), |
31 | length: object.length, |
32 | hash: hasher.digest('hex') |
33 | }}) |
34 | read(null, next) |
35 | }) |
36 | ) |
37 | }) |
38 | }, |
39 | updateSink: pull.drain(function (update) { |
40 | process.send({update: update}) |
41 | }) |
42 | }), |
43 | toPull(process.stdout, function (err) { |
44 | if (err) |
45 | throw err |
46 | process.disconnect() |
47 | }) |
48 | ) |
49 |
Built with git-ssb-web