   constructor: (@version) ->
     @state = IdleState
     @feedUrl = "https://atom.io/api/updates?version=#{@version}"
+
+    process.nextTick => @setupAutoUpdater()
+
+  setupAutoUpdater: ->
+    autoUpdater ?= require 'auto-updater'
 
     if process.platform is 'win32'
       autoUpdater.checkForUpdates = => @checkForUpdatesShim()

  checkForUpdatesShim: ->
    autoUpdater.emit 'checking-for-update'

    # Do this in a next tick since requiring https can be slow the first time
    # and this check shouldn't interfere with startup time.
    process.nextTick =>
      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

autoUpdater = null
_ = require 'underscore-plus'
{EventEmitter} = require 'events'

