forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
26 lines (23 loc) · 835 Bytes
/
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
const { app } = require('electron');
const net = require('net');
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
process.on('uncaughtException', () => {
app.exit(1);
});
app.whenReady().then(() => {
const lastArg = process.argv[process.argv.length - 1];
const client = net.connect(socketPath);
client.once('connect', () => {
client.end(lastArg);
});
client.once('end', () => {
if (lastArg === '--first') {
// Once without execPath specified
app.relaunch({ args: process.argv.slice(1, -1).concat('--second') });
} else if (lastArg === '--second') {
// And once with execPath specified
app.relaunch({ execPath: process.argv[0], args: process.argv.slice(1, -1).concat('--third') });
}
app.exit(0);
});
});