From cacaba936b592c995f23c07b1371e762c20dffe0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 2 Dec 2014 11:29:34 -0800 Subject: [PATCH] Add restart helper on Windows --- src/browser/auto-updater-win32.coffee | 7 ++----- src/browser/squirrel-update.coffee | 7 ++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/browser/auto-updater-win32.coffee b/src/browser/auto-updater-win32.coffee index 85cff0c42..d57253075 100644 --- a/src/browser/auto-updater-win32.coffee +++ b/src/browser/auto-updater-win32.coffee @@ -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) -> diff --git a/src/browser/squirrel-update.coffee b/src/browser/squirrel-update.coffee index 14aa8b6ee..e976b15bb 100644 --- a/src/browser/squirrel-update.coffee +++ b/src/browser/squirrel-update.coffee @@ -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]