Use spawn instead of execFile for squirrel events

This commit is contained in:
Kevin Sawicki
2014-11-13 15:00:29 -08:00
parent 5770366c00
commit 9c675f387a

View File

@@ -2,24 +2,20 @@ app = require 'app'
ChildProcess = require 'child_process'
path = require 'path'
updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe')
exeName = path.basename(process.execPath)
createShortcut = ->
ChildProcess.execFile updateDotExe, ['--createShortcut', exeName], ->
app.quit()
removeShortcut = ->
ChildProcess.execFile updateDotExe, ['--removeShortcut', exeName], ->
app.quit()
spawnUpdateAndQuit = (option) ->
updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe')
exeName = path.basename(process.execPath)
updateProcess = ChildProcess.spawn(updateDotExe, ["--#{option}", exeName])
updateProcess.on 'error', -> # Ignore errors
updateProcess.on 'close', -> app.quit()
module.exports = ->
switch process.argv[1]
when '--squirrel-install', '--squirrel-updated'
createShortcut()
spawnUpdateAndQuit('createShortcut')
true
when '--squirrel-uninstall'
removeShortcut()
spawnUpdateAndQuit('removeShortcut')
true
when '--squirrel-obsolete'
app.quit()