main.js 355 B

123456789101112131415161718
  1. const { app } = require('electron');
  2. app.whenReady().then(() => {
  3. console.log('started'); // ping parent
  4. });
  5. const gotTheLock = app.requestSingleInstanceLock();
  6. app.on('second-instance', (event, args, workingDirectory) => {
  7. setImmediate(() => {
  8. console.log(JSON.stringify(args));
  9. app.exit(0);
  10. });
  11. });
  12. if (!gotTheLock) {
  13. app.exit(1);
  14. }