2018-09-13 16:10:51 +00:00
|
|
|
const { app } = require('electron');
|
2016-06-03 03:12:20 +00:00
|
|
|
const net = require('net');
|
|
|
|
|
2016-06-29 16:37:10 +00:00
|
|
|
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
|
2016-06-03 03:12:20 +00:00
|
|
|
|
|
|
|
process.on('uncaughtException', () => {
|
|
|
|
app.exit(1);
|
|
|
|
});
|
|
|
|
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(() => {
|
2018-10-02 01:56:31 +00:00
|
|
|
const lastArg = process.argv[process.argv.length - 1];
|
2016-06-03 03:12:20 +00:00
|
|
|
const client = net.connect(socketPath);
|
|
|
|
client.once('connect', () => {
|
|
|
|
client.end(String(lastArg === '--second'));
|
|
|
|
});
|
|
|
|
client.once('end', () => {
|
2021-03-07 07:30:43 +00:00
|
|
|
if (lastArg !== '--second') {
|
|
|
|
app.relaunch({ args: process.argv.slice(1).concat('--second') });
|
|
|
|
}
|
2016-06-03 03:12:20 +00:00
|
|
|
app.exit(0);
|
|
|
|
});
|
|
|
|
});
|