git ssb

1+

Dominic / exed



Tree: 1441fdeb23ee6ecb5c47ac1013bcecd533a96d62

Files: 1441fdeb23ee6ecb5c47ac1013bcecd533a96d62 / bash.js

730 bytesRaw
1var cp = require('child_process')
2var Utf8 = require('pull-utf8-decoder')
3var pull = require('pull-stream')
4var toPull = require('stream-to-pull-stream')
5var h = require('hyperscript')
6
7exports.gives = 'command'
8exports.create = function (api) {
9 return function (cmd) {
10 return function (cb) {
11 var p = cp.spawn('bash', ['-c', cmd])
12 var el = h('pre')
13 console.log('bash', cmd, p)
14
15 pull(
16 toPull.source(p.stdout),
17 Utf8(),
18 pull.drain(function (str) {
19 console.log(str)
20 el.appendChild(document.createTextNode(str))
21 })
22 )
23
24 p.on('close', function (code) {
25 el.appendChild(h('label', 'code: '+code))
26 })
27
28 cb(null, el)
29 }
30 }
31}
32

Built with git-ssb-web