electron/spec/fixtures/api/relaunch/main.js

24 lines
608 B
JavaScript
Raw Normal View History

2018-09-14 02:10:51 +10:00
const { app } = require('electron')
2016-06-03 12:12:20 +09:00
const net = require('net')
2016-06-29 09:37:10 -07:00
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch'
2016-06-03 12:12:20 +09:00
process.on('uncaughtException', () => {
app.exit(1)
})
app.once('ready', () => {
const lastArg = process.argv[process.argv.length - 1]
2016-06-03 12:12:20 +09:00
const client = net.connect(socketPath)
client.once('connect', () => {
client.end(String(lastArg === '--second'))
})
client.once('end', () => {
app.exit(0)
})
if (lastArg !== '--second') {
2018-09-14 02:10:51 +10:00
app.relaunch({ args: process.argv.slice(1).concat('--second') })
2016-06-03 12:12:20 +09:00
}
})