Add Open with Atom file context menu

This commit is contained in:
Kevin Sawicki
2014-11-18 09:52:17 -08:00
parent 9bd7141359
commit 8e53b2d507

View File

@@ -28,11 +28,40 @@ exports.spawn = (args, callback) ->
exports.existsSync = ->
fs.existsSync(updateDotExe)
installContextMenu = (callback) ->
fileKeyPath = 'HKCU\\Software\\Classes\\*\\shell\\Atom'
spawnReg = (args) ->
regProcess = ChildProcess.spawn('reg.exe', args)
error = null
regProcess.on 'error', (processError) -> error ?= processError
regProcess.on 'close', (code, signal) ->
error ?= new Error("Command failed: #{signal}") if code isnt 0
error?.code ?= code
callback(error)
installFileMenu = ->
args = [fileKeyPath, '/ve', '/d', 'Open with Atom']
spawnReg args, (error) ->
return callback(error) if error?
args = [fileKeyPath, '/v', 'Icon', '/d', process.execPath]
spawnReg args, (error) ->
return callback(error) if error?
args = ["#{fileKeyPath}\\command", '/ve', '/d', process.execPath]
spawnReg(args, callback)
installFileMenu(callback)
# Handle squirrel events denoted by --squirrel-* command line arguments.
exports.handleStartupEvent = ->
switch process.argv[1]
when '--squirrel-install', '--squirrel-updated'
exports.spawn ['--createShortcut', exeName], -> app.quit()
exports.spawn ['--createShortcut', exeName], ->
installContextMenu ->
app.quit()
true
when '--squirrel-uninstall'
exports.spawn ['--removeShortcut', exeName], -> app.quit()