Ensure install & upgrade fix up previous shell paths

This commit is contained in:
Damien Guard
2016-07-17 22:42:08 -07:00
parent 5a8ced324e
commit 1610bcedb1
2 changed files with 23 additions and 19 deletions

View File

@@ -125,31 +125,35 @@ exports.restartAtom = (app) ->
app.once 'will-quit', -> Spawner.spawn(path.join(binFolder, 'atom.cmd'), args)
app.quit()
updateContextMenus = (callback) ->
WinShell.fileContextMenu.update ->
WinShell.folderContextMenu.update ->
WinShell.folderBackgroundContextMenu.update ->
callback
# Handle squirrel events denoted by --squirrel-* command line arguments.
exports.handleStartupEvent = (app, squirrelCommand) ->
switch squirrelCommand
when '--squirrel-install'
createShortcuts ->
WinShell.fileHandler.register ->
addCommandsToPath ->
app.quit()
addCommandsToPath ->
WinShell.fileHandler.register ->
updateContextMenus ->
app.quit()
true
when '--squirrel-updated'
updateShortcuts ->
WinShell.fileHandler.update ->
WinShell.fileContextMenu.update ->
WinShell.folderContextMenu.update ->
WinShell.folderBackgroundContextMenu.update ->
addCommandsToPath ->
app.quit()
addCommandsToPath ->
updateContextMenus ->
app.quit()
true
when '--squirrel-uninstall'
removeShortcuts ->
WinShell.fileHandler.deregister ->
WinShell.fileContextMenu.deregister ->
WinShell.folderContextMenu.deregister ->
WinShell.folderBackgroundContextMenu.deregister ->
removeCommandsFromPath ->
removeCommandsFromPath ->
WinShell.fileHandler.deregister ->
WinShell.fileContextMenu.deregister ->
WinShell.folderContextMenu.deregister ->
WinShell.folderBackgroundContextMenu.deregister ->
app.quit()
true
when '--squirrel-obsolete'

View File

@@ -17,7 +17,7 @@ class ShellOption
doneCount = @parts.length
@parts.forEach((part) =>
reg = new Registry({hive: 'HKCU', key: if part.key? then "#{@key}\\#{part.key}" else @key})
reg.create( -> reg.set part.name, Registry.REG_SZ, part.value, -> callback() if doneCount-- is 0))
reg.create( -> reg.set part.name, Registry.REG_SZ, part.value, -> callback() if --doneCount is 0))
deregister: (callback) =>
@isRegistered (isRegistered) =>
if isRegistered
@@ -26,11 +26,11 @@ class ShellOption
callback null, false
update: (callback) =>
new Registry({hive: 'HKCU', key: "#{@key}\\#{@parts[0].key}"})
.get @parts[0].name, (err, val) ->
if err? or not val.value.endsWith '\\' + exeName
callback err, val
.get @parts[0].name, (err, val) =>
if err? or not val.value.includes '\\' + exeName
callback(err)
else
register callback
@register callback
exports.appName = appName