electron/spec/fixtures/api/relaunch/main.js
Samuel Attard 122685194a
build: add import/order eslint rule (#44085)
* build: add import/order eslint rule

* chore: run lint:js --fix
2024-10-02 19:10:44 -07:00

27 lines
841 B
JavaScript

const { app } = require('electron');
const net = require('node: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);
});
});