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

19 lines
396 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const { app } = require('electron');
app.whenReady().then(() => {
2020-03-20 20:28:31 +00:00
console.log('started'); // ping parent
});
2020-03-20 20:28:31 +00:00
const gotTheLock = app.requestSingleInstanceLock();
app.on('second-instance', (event, args, workingDirectory, data) => {
setImmediate(() => {
console.log([JSON.stringify(args), JSON.stringify(data)].join('||'));
2020-03-20 20:28:31 +00:00
app.exit(0);
});
});
if (!gotTheLock) {
2020-03-20 20:28:31 +00:00
app.exit(1);
}