2015-06-15 18:28:47 +00:00
|
|
|
switch process.platform
|
|
|
|
when 'win32'
|
2015-06-16 09:04:37 +00:00
|
|
|
autoUpdater = require('./auto-updater/auto-updater-win')
|
2015-06-16 09:48:39 +00:00
|
|
|
else
|
2015-06-16 09:04:37 +00:00
|
|
|
# take the default binding for the current platform
|
2015-06-16 14:13:23 +00:00
|
|
|
autoUpdater = process.atomBinding('auto_updater').autoUpdater
|
|
|
|
EventEmitter = require('events').EventEmitter
|
|
|
|
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()
|
2013-06-03 10:21:13 +00:00
|
|
|
|
2014-02-17 06:51:22 +00:00
|
|
|
autoUpdater.quitAndInstall = ->
|
2014-02-17 07:05:34 +00:00
|
|
|
# If we don't have any window then quitAndInstall immediately.
|
|
|
|
BrowserWindow = require 'browser-window'
|
|
|
|
windows = BrowserWindow.getAllWindows()
|
|
|
|
if windows.length is 0
|
2014-05-07 03:32:06 +00:00
|
|
|
@_quitAndInstall()
|
2014-02-17 07:05:34 +00:00
|
|
|
return
|
|
|
|
|
2014-02-17 06:51:22 +00:00
|
|
|
# Do the restart after all windows have been closed.
|
|
|
|
app = require 'app'
|
|
|
|
app.removeAllListeners 'window-all-closed'
|
2014-05-07 03:32:06 +00:00
|
|
|
app.once 'window-all-closed', @_quitAndInstall.bind(this)
|
2014-02-17 08:25:00 +00:00
|
|
|
win.close() for win in windows
|
2014-02-17 06:51:22 +00:00
|
|
|
|
2013-06-03 10:21:13 +00:00
|
|
|
module.exports = autoUpdater
|