Install atom command asynchronously

This commit is contained in:
Kevin Sawicki
2013-04-23 11:03:55 -07:00
parent b27b0c7d4f
commit 2f5a99fac2
3 changed files with 27 additions and 8 deletions

View File

@@ -72,13 +72,21 @@ window.shutdown = ->
window.project = null
window.git = null
window.installAtomCommand = (commandPath) ->
return if fsUtils.exists(commandPath)
window.installAtomCommand = (commandPath, done) ->
fs.exists commandPath, (exists) ->
return if exists
bundledCommandPath = fsUtils.resolve(window.resourcePath, 'atom.sh')
if bundledCommandPath?
fsUtils.write(commandPath, fsUtils.read(bundledCommandPath))
fs.chmod(commandPath, 0o755, commandPath)
bundledCommandPath = fsUtils.resolve(window.resourcePath, 'atom.sh')
if bundledCommandPath?
fs.readFile bundledCommandPath, (error, data) ->
if error?
console.warn "Failed to install `atom` binary", error
else
fsUtils.writeAsync commandPath, data, (error) ->
if error?
console.warn "Failed to install `atom` binary", error
else
fs.chmod(commandPath, 0o755, commandPath)
window.handleWindowEvents = ->
$(window).command 'window:toggle-full-screen', => atom.toggleFullScreen()