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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
840 B
JavaScript
Raw Normal View History

2018-09-13 16:10:51 +00:00
const { app } = require('electron');
const net = require('node:net');
2016-06-03 03:12:20 +00:00
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);
});
app.whenReady().then(() => {
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(lastArg);
2016-06-03 03:12:20 +00:00
});
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') });
}
2016-06-03 03:12:20 +00:00
app.exit(0);
});
});