mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Save point before Boss Fight
This commit is contained in:
committed by
Kevin Sawicki
parent
379bd852d2
commit
7381bd09b1
@@ -1,15 +1,58 @@
|
||||
_ = require 'underscore-plus'
|
||||
path = require 'path'
|
||||
fs = require 'fs'
|
||||
|
||||
{EventEmitter} = require 'events'
|
||||
{BufferedProcess} = require 'atom'
|
||||
|
||||
module.exports =
|
||||
class AutoUpdater
|
||||
_.extend @prototype, EventEmitter.prototype
|
||||
|
||||
setFeedUrl: ->
|
||||
console.log 'setFeedUrl'
|
||||
setFeedUrl: (url) ->
|
||||
@updateUrl = url
|
||||
|
||||
quitAndInstall: ->
|
||||
console.log 'quitAndInstall'
|
||||
|
||||
checkForUpdates: ->
|
||||
console.log 'checkForUpdates'
|
||||
throw new Error("Update URL is not set") unless @updateUrl
|
||||
|
||||
emit 'checking-for-update'
|
||||
|
||||
updateDotExe = path.join(path.dirName(process.execPath), '..', 'update.exe')
|
||||
unless fs.existsSync(updateDotExe)
|
||||
console.log 'Running developer or Chocolatey version of Atom, skipping'
|
||||
emit 'update-not-available'
|
||||
return
|
||||
|
||||
args = ['--update', @updateUrl]
|
||||
updateJson = ""
|
||||
|
||||
ps = new BufferedProcess
|
||||
command: updateDotExe,
|
||||
args,
|
||||
stdout: (output) -> updateJson += output
|
||||
exit: (exitCode) ->
|
||||
unless exitCode is 0
|
||||
console.log 'Failed to update: ' + exitCode + ' - ' + updateJson
|
||||
emit 'update-not-available'
|
||||
return
|
||||
|
||||
updateInfo = null
|
||||
try
|
||||
updateInfo = JSON.parse updateJson
|
||||
catch ex
|
||||
console.log "Update JSON isn't valid: " + updateJson
|
||||
emit 'update-not-available'
|
||||
return
|
||||
|
||||
unless updateInfo and updateInfo.releasesToApply.length > 0
|
||||
console.log "You're on the latest version!"
|
||||
emit 'update-not-available'
|
||||
return
|
||||
|
||||
# We don't have separate "check for update" and "download" in Squirrel,
|
||||
# we always just download
|
||||
emit 'update-available'
|
||||
emit 'update-downloaded', {}
|
||||
|
||||
Reference in New Issue
Block a user