Files: 1441fdeb23ee6ecb5c47ac1013bcecd533a96d62 / bash.js
730 bytesRaw
1 | var cp = require('child_process') |
2 | var Utf8 = require('pull-utf8-decoder') |
3 | var pull = require('pull-stream') |
4 | var toPull = require('stream-to-pull-stream') |
5 | var h = require('hyperscript') |
6 | |
7 | exports.gives = 'command' |
8 | exports.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