-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
53 lines (38 loc) · 1.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!doctype html>
<body>
</body>
<script>
var streams = require('stream')
var ipc = require('electron').ipcRenderer
var opts = require('querystring').parse(decodeURIComponent(location.search.substring(1)))
process.argv = opts.argv
process.stdin.isTTY = opts.stdin == 'true'
process.stdout.isTTY = opts.stdout == 'true'
process.stderr.isTTY = opts.stderr == 'true'
process.title = 'electro'
var stdin = process.stdin// = new streams.Readable()
stdin._read = function () {
this.push('')
}
ipc.on('process.stdin', function (data, data2) {
if('string' == typeof data2)
stdin.push(new Buffer(data2, 'base64'))
else if('string' === typeof data)
stdin.push(new Buffer(data1, 'base64'))
else stdin.push(null)
})
function stdo (name) {
var stream = process[name] = new streams.Writable()
var event = 'process.'+name
stream._write = function (data, enc, callback) {
if(Buffer.isBuffer(data))
ipc.send(event, data.toString('base64'))
else
ipc.send(event, new Buffer(data, enc || 'utf8').toString('base64'))
callback()
}
}
stdo('stdout')
stdo('stderr')
require(require('path').resolve(process.argv[1]))
</script>