You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
900 B

// @flow
import { createCommand, Command } from 'helpers/ipc'
import { Observable } from 'rxjs'
type Input = void
type Result = void
const cmd: Command<Input, Result> = createCommand('main:quitAndInstallElectronUpdate', () =>
Observable.create(o => {
const { app, BrowserWindow } = require('electron')
const { autoUpdater } = require('electron-updater')
const browserWindows = BrowserWindow.getAllWindows()
// Fixes quitAndInstall not quitting on macOS, as suggested on
// https://github.com/electron-userland/electron-builder/issues/1604#issuecomment-306709572
app.removeAllListeners('window-all-closed')
browserWindows.forEach(browserWindow => {
browserWindow.removeAllListeners('close')
})
// couldn't find a way to catch if fail ¯\_(ツ)_/¯
autoUpdater.quitAndInstall(false)
o.complete()
return () => {}
}),
)
export default cmd