Disable the updates shim on Win32, include our own JS version

This commit is contained in:
Paul Betts
2014-10-13 13:46:47 -07:00
committed by Kevin Sawicki
parent a9ee6e5d43
commit 379bd852d2
2 changed files with 18 additions and 21 deletions

View File

@@ -20,10 +20,10 @@ class AutoUpdateManager
process.nextTick => @setupAutoUpdater()
setupAutoUpdater: ->
autoUpdater = require 'auto-updater'
if process.platform is 'win32'
autoUpdater.checkForUpdates = => @checkForUpdatesShim()
autoUpdater = require 'auto-updater-win32'
else
autoUpdater = require 'auto-updater'
autoUpdater.setFeedUrl @feedUrl
@@ -48,24 +48,6 @@ class AutoUpdateManager
unless /\w{7}/.test(@version)
@check(hidePopups: true)
# Windows doesn't have an auto-updater, so use this method to shim the events.
checkForUpdatesShim: ->
autoUpdater.emit 'checking-for-update'
https = require 'https'
request = https.get @feedUrl, (response) ->
if response.statusCode == 200
body = ""
response.on 'data', (chunk) -> body += chunk
response.on 'end', ->
{notes, name} = JSON.parse(body)
autoUpdater.emit 'update-downloaded', null, notes, name
else
autoUpdater.emit 'update-not-available'
request.on 'error', (error) ->
autoUpdater.emit 'error', null, error.message
emitUpdateAvailableEvent: (windows...) ->
return unless @releaseVersion? and @releaseNotes
for atomWindow in windows

View File

@@ -0,0 +1,15 @@
_ = require 'underscore-plus'
{EventEmitter} = require 'events'
module.exports =
class AutoUpdater
_.extend @prototype, EventEmitter.prototype
setFeedUrl: ->
console.log 'setFeedUrl'
quitAndInstall: ->
console.log 'quitAndInstall'
checkForUpdates: ->
console.log 'checkForUpdates'