forked from holepunchto/pear
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.js
More file actions
35 lines (34 loc) · 773 Bytes
/
Copy pathboot.js
File metadata and controls
35 lines (34 loc) · 773 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
27
28
29
30
31
32
33
34
35
/** @typedef {import('pear-interface')} */
'use strict'
const { isElectron, isElectronRenderer, isElectronWorker } = require('which-runtime')
const BOOT_SIDECAR = 1
const BOOT_CLI = 2
const BOOT_ELECTRON = 3
const BOOT_ELECTRON_PRELOAD = 4
switch (getBootType()) {
case BOOT_SIDECAR: {
require('./sidecar.js')
break
}
case BOOT_CLI: {
require('./cli.js')
break
}
case BOOT_ELECTRON: {
require('./electron-main.js')
break
}
case BOOT_ELECTRON_PRELOAD: {
require('./preload.js')
break
}
}
function getBootType () {
if (isElectron) {
return (isElectronRenderer || isElectronWorker)
? BOOT_ELECTRON_PRELOAD
: BOOT_ELECTRON
}
if (global.Bare.argv[1] === '--sidecar') return BOOT_SIDECAR
return BOOT_CLI
}