Skip to content

Commit

Permalink
Prevent multiple instances of app from running fixes #34
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed Mar 7, 2017
1 parent 7682ee1 commit e06c08e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ log.info(`Running version ${version}`)
let releaseStage = isDev ? 'development' : 'production'
bugsnag.register('032040bba551785c7846442332cc067f', {autoNotify: true, appVersion: version, releaseStage: releaseStage})


const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
focusMainWindow()
}
})
if (shouldQuit) {
app.quit()
}


const returnFocusOsascript = `tell application "System Events"
set activeApp to name of application processes whose frontmost is true
if (activeApp = {"Mobster"} or activeApp = {"Electron"}) then
Expand Down

0 comments on commit e06c08e

Please sign in to comment.