mirror of
https://github.com/atom/atom.git
synced 2026-02-18 02:21:43 -05:00
Use spawn instead of execFile for squirrel events
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user