-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.js
69 lines (61 loc) · 1.97 KB
/
main.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const Path = require('path')
const { app, ipcMain, BrowserWindow } = require('electron')
const Helpers = require('./helpers')
require('electron-debug')({ showDevTools: true })
require('electron-context-menu')()
const options = Helpers.getElectronOptions()
const denodeOptions = Helpers.getDenodeOptions(options.manifest)
if (denodeOptions.DENODE_INSECURE) {
app.commandLine.appendSwitch('--ignore-certificate-errors')
}
app.setName('denode')
app.setPath('userData', Path.join(Path.dirname(app.getPath('userData')), 'denode'))
app.setPath('userCache', Path.join(Path.dirname(app.getPath('userCache')), 'denode'))
app.on('window-all-closed', function() {
app.quit()
})
app.on('ready', Helpers.installExtensions(function() {
const electronOptions = Object.assign({}, options.electron)
if (electronOptions.hide) {
Object.assign(electronOptions, {
height: 400,
})
}
const window = new BrowserWindow(electronOptions)
window.loadURL(`file://${Path.normalize(Path.join(__dirname, '..', 'renderer', 'index.html'))}`)
window.webContents.openDevTools({ mode: 'bottom' })
if (options.electron.hide) {
window.webContents.once('devtools-closed', function() {
window.hide()
setImmediate(() => window.close())
})
}
window.webContents.on('dom-ready', function() {
window.webContents.send('setup', JSON.stringify({
argv: process.argv.slice(1),
request: process.argv[2],
stdout: {
isTTY: process.stdout.isTTY,
columns: process.stdout.columns,
rows: process.stdout.rows,
},
stderr: {
isTTY: process.stderr.isTTY,
columns: process.stderr.columns,
rows: process.stderr.rows,
},
}))
})
}))
ipcMain.on('stdout', function(_, data) {
process.stdout.write(data)
})
ipcMain.on('stderr', function(_, data) {
process.stderr.write(data)
})
process.stdin.on('data', function(chunk) {
if (window) {
window.webContents.send('stdin', chunk.toString())
}
})
process.stdin.resume()