Skip to content

Commit

Permalink
πŸ‘Ÿ Update to new single instance api
Browse files Browse the repository at this point in the history
  • Loading branch information
albertzak committed Jan 22, 2019
1 parent 8aa3af8 commit 6c4e291
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/electron/main/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const { app } = require('electron')
const logger = require('./logger')

const handleStartupEvent = callback => {
const isSecondInstance = app.makeSingleInstance((argv, cwd) => {
const gotTheLock = app.requestSingleInstanceLock()

app.on('second-instance', (argv, cwd) => {
logger.info('[CLI] Other instance was launched in', cwd, argv)

// Quit old instance when headless is started
Expand All @@ -20,7 +22,7 @@ const handleStartupEvent = callback => {

// Only quit newer instance if it is not headless
const isHeadless = process.argv.join(' ').indexOf('headless') !== -1
if (isSecondInstance && !isHeadless) {
if (!gotTheLock && !isHeadless) {
logger.info('[CLI] Quitting because other instance is already running')
return true
}
Expand Down

0 comments on commit 6c4e291

Please sign in to comment.