Add initial SquirrelUpdate specs

This commit is contained in:
Kevin Sawicki
2014-12-17 10:47:39 -08:00
parent bbf6930061
commit 1c81aa90c0
4 changed files with 100 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ class AutoUpdater
quitAndInstall: ->
if SquirrelUpdate.existsSync()
SquirrelUpdate.restartAtom()
SquirrelUpdate.restartAtom(require('app'))
else
require('auto-updater').quitAndInstall()

View File

@@ -26,7 +26,8 @@ fs.lstatSyncNoException = (pathToStat) ->
start = ->
if process.platform is 'win32'
SquirrelUpdate = require './squirrel-update'
return if SquirrelUpdate.handleStartupEvent()
squirrelCommand = process.argv[1]
return if SquirrelUpdate.handleStartupEvent(app, squirrelCommand)
args = parseCommandLine()

View File

@@ -1,4 +1,3 @@
app = require 'app'
ChildProcess = require 'child_process'
fs = require 'fs-plus'
path = require 'path'
@@ -198,15 +197,15 @@ exports.existsSync = ->
fs.existsSync(updateDotExe)
# Restart Atom using the version pointed to by the atom.cmd shim
exports.restartAtom = ->
exports.restartAtom = (app) ->
if projectPath = global.atomApplication?.lastFocusedWindow?.projectPath
args = [projectPath]
app.once 'will-quit', -> spawn(path.join(binFolder, 'atom.cmd'), args)
app.quit()
# Handle squirrel events denoted by --squirrel-* command line arguments.
exports.handleStartupEvent = ->
switch process.argv[1]
exports.handleStartupEvent = (app, squirrelCommand) ->
switch squirrelCommand
when '--squirrel-install'
createShortcuts ->
installContextMenu ->