electron/atom/browser/api/lib/auto-updater.coffee

31 lines
970 B
CoffeeScript
Raw Normal View History

2015-06-15 18:28:47 +00:00
switch process.platform
when 'win32'
autoUpdater = require('./auto-updater/auto-updater-win')
else
# take the default binding for the current platform
autoUpdater = process.atomBinding('auto_updater').autoUpdater
2015-06-15 18:28:47 +00:00
2013-06-03 09:59:34 +00:00
EventEmitter = require('events').EventEmitter
2014-04-17 09:26:21 +00:00
autoUpdater.__proto__ = EventEmitter.prototype
2013-06-03 09:59:34 +00:00
2014-01-21 14:13:34 +00:00
autoUpdater.on 'update-downloaded-raw', (args...) ->
2014-02-03 20:39:54 +00:00
args[3] = new Date(args[3]) # releaseDate
2014-01-21 14:13:34 +00:00
@emit 'update-downloaded', args..., => @quitAndInstall()
autoUpdater.quitAndInstall = ->
# If we don't have any window then quitAndInstall immediately.
BrowserWindow = require 'browser-window'
windows = BrowserWindow.getAllWindows()
if windows.length is 0
@_quitAndInstall()
return
# Do the restart after all windows have been closed.
app = require 'app'
app.removeAllListeners 'window-all-closed'
app.once 'window-all-closed', @_quitAndInstall.bind(this)
win.close() for win in windows
module.exports = autoUpdater