-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·27 lines (24 loc) · 744 Bytes
/
cli.js
File metadata and controls
executable file
·27 lines (24 loc) · 744 Bytes
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
#!/usr/bin/env electron
var electron = require('electron')
var path = require('path')
electron.app.on('ready', function () {
var win = new electron.BrowserWindow({show: false})
win.loadURL('file://' + path.join(__dirname, 'index.html'))
win.webContents.on('did-finish-load', function () {
win.webContents.send('args', process.argv)
})
var reading = false
electron.ipcMain.on('stdin.read', onread)
process.stdin.on('readable', function () {
if (reading) onread()
})
process.stdin.on('end', function () {
win.webContents.send('stdin.data', null)
})
function onread () {
var buf = process.stdin.read()
reading = false
if (buf) win.webContents.send('stdin.data', buf)
else reading = true
}
})