Add restart helper on Windows

This commit is contained in:
Kevin Sawicki
2014-12-02 11:29:34 -08:00
parent b20589fbb6
commit cacaba936b
2 changed files with 8 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
{EventEmitter} = require 'events'
_ = require 'underscore-plus'
shellAutoUpdater = require 'auto-updater'
SquirrelUpdate = require './squirrel-update'
class AutoUpdater
@@ -12,11 +11,9 @@ class AutoUpdater
console.log 'restarting new atom.exe'
if SquirrelUpdate.existsSync()
SquirrelUpdate.spawn ['--processStart', 'atom.exe'], ->
console.log 'spawned new atom.exe'
shellAutoUpdater.quitAndInstall()
SquirrelUpdate.restartAtom()
else
shellAutoUpdater.quitAndInstall()
require('auto-updater').quitAndInstall()
downloadUpdate: (callback) ->
SquirrelUpdate.spawn ['--download', @updateUrl], (error, stdout) ->

View File

@@ -36,7 +36,7 @@ spawn = (command, args, callback) ->
error ?= new Error("Command failed: #{signal ? code}") if code isnt 0
error?.code ?= code
error?.stdout ?= stdout
callback(error, stdout)
callback?(error, stdout)
# Spawn reg.exe and callback when it completes
spawnReg = (args, callback) ->
@@ -175,6 +175,11 @@ exports.spawn = spawnUpdate
exports.existsSync = ->
fs.existsSync(updateDotExe)
# Restart Atom using the version pointed to by the atom.cmd shim
exports.restartAtom = ->
app.once 'will-quit', -> spawn(path.join(binFolder, 'atom.cmd'))
app.quit()
# Handle squirrel events denoted by --squirrel-* command line arguments.
exports.handleStartupEvent = ->
switch process.argv[1]