-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (43 loc) · 1.18 KB
/
index.js
File metadata and controls
53 lines (43 loc) · 1.18 KB
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
const {app, BrowserWindow} = require('electron')
const {ipcMain} = require('electron')
const initApp = require('../../util/init-app')
const createIndex = require('../../util/create-index')
const coerceOpts = require('./coerce-opts')
const run = require('./run')
/** Create runner app
*
* @param {object} _opts
* - input {string or array of strings}
* - debug {boolean} turn on debugging tooling
* - component {string, object, array of a strings or array of objects}
* - name {string}
* - path {string}
* - ... other options to be passed to methods
*
* @return {object} app
*/
function createApp (_opts) {
initApp(app, ipcMain)
const opts = coerceOpts(_opts)
let win = null
let index = null
app.on('ready', () => {
win = new BrowserWindow(opts._browserWindowOpts)
if (opts.debug) {
win.openDevTools()
}
win.on('closed', () => {
win = null
index.destroy()
})
createIndex(opts.component, opts, (_index) => {
index = _index
win.loadURL(`file://${index.path}`)
})
win.webContents.once('did-finish-load', () => {
run(app, win, ipcMain, opts)
})
})
return app
}
module.exports = createApp