diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index affabc0ae..bf773fdb0 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -72,7 +72,7 @@ class AtomApplication @listenForArgumentsFromNewProcess() @setupJavaScriptArguments() @handleEvents() - @checkForUpdates() + @setupAutoUpdater() @openWithOptions(options) @@ -117,16 +117,28 @@ class AtomApplication app.commandLine.appendSwitch 'js-flags', '--harmony_collections --harmony-proxies' # Private: Enable updates unless running from a local build of Atom. - checkForUpdates: -> - versionIsSha = /\w{7}/.test @version + setupAutoUpdater: -> + autoUpdater.setFeedUrl "http://localhost:9393/releases/latest?version=#{@version}" - if versionIsSha - autoUpdater.setAutomaticallyDownloadsUpdates false - autoUpdater.setAutomaticallyChecksForUpdates false - else - autoUpdater.setAutomaticallyDownloadsUpdates true - autoUpdater.setAutomaticallyChecksForUpdates true - autoUpdater.checkForUpdatesInBackground() + autoUpdater.on 'checking-for-update', => + @applicationMenu.showInstallUpdateItem(false) + @applicationMenu.showCheckForUpdateItem(false) + + autoUpdater.on 'update-not-available', => + @applicationMenu.showInstallUpdateItem(false) + @applicationMenu.showCheckForUpdateItem(true) + + autoUpdater.on 'update-downloaded', (event, releaseNotes, releaseName, releaseDate, releaseURL) => + atomWindow.sendCommand('window:update-available', releaseName) for atomWindow in @windows + @applicationMenu.showInstallUpdateItem(true) + @applicationMenu.showCheckForUpdateItem(false) + @updateVersion = releaseName + + autoUpdater.on 'error', (event, message)=> + @applicationMenu.showInstallUpdateItem(false) + @applicationMenu.showCheckForUpdateItem(true) + + autoUpdater.checkForUpdates() # Private: Registers basic application commands, non-idempotent. handleEvents: -> @@ -170,12 +182,6 @@ class AtomApplication event.preventDefault() @openUrl({urlToOpen, @devMode}) - autoUpdater.on 'ready-for-update-on-quit', (event, version, quitAndUpdateCallback) => - event.preventDefault() - @updateVersion = version - @applicationMenu.showDownloadUpdateItem(version, quitAndUpdateCallback) - atomWindow.sendCommand('window:update-available', version) for atomWindow in @windows - # A request from the associated render process to open a new render process. ipc.on 'open', (processId, routingId, options) => if options? diff --git a/src/browser/main.coffee b/src/browser/main.coffee index 5d4a66224..c72081cd7 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -1,6 +1,5 @@ global.shellStartTime = Date.now() -autoUpdater = require 'auto-updater' crashReporter = require 'crash-reporter' app = require 'app' fs = require 'fs' @@ -42,7 +41,6 @@ start = -> app.on 'will-finish-launching', -> setupCrashReporter() - setupAutoUpdater() app.on 'finish-launching', -> app.removeListener 'open-file', addPathToOpen @@ -66,9 +64,6 @@ global.devResourcePath = path.join(app.getHomeDir(), 'github', 'atom') setupCrashReporter = -> crashReporter.start(productName: 'Atom', companyName: 'GitHub') -setupAutoUpdater = -> - autoUpdater.setFeedUrl 'https://speakeasy.githubapp.com/apps/27/appcast.xml' - parseCommandLine = -> version = app.getVersion() options = optimist(process.argv[1..])