mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Install atom command asynchronously
This commit is contained in:
@@ -165,8 +165,12 @@ describe "Window", ->
|
||||
it "copies atom.sh to the specified path", ->
|
||||
expect(fsUtils.exists(commandPath)).toBeFalsy()
|
||||
window.installAtomCommand(commandPath)
|
||||
expect(fsUtils.exists(commandPath)).toBeTruthy()
|
||||
expect(fsUtils.read(commandPath).length).toBeGreaterThan 1
|
||||
|
||||
waitsFor ->
|
||||
fsUtils.exists(commandPath)
|
||||
|
||||
runs ->
|
||||
expect(fsUtils.read(commandPath).length).toBeGreaterThan 1
|
||||
|
||||
describe ".deserialize(state)", ->
|
||||
class Foo
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -155,6 +155,13 @@ module.exports =
|
||||
mkdirp.sync(@directory(path))
|
||||
fs.writeFileSync(path, content)
|
||||
|
||||
writeAsync: (path, content, callback) ->
|
||||
mkdirp @directory(path), (error) ->
|
||||
if error?
|
||||
callback?(error)
|
||||
else
|
||||
fs.writeFile(path, content, callback)
|
||||
|
||||
makeDirectory: (path) ->
|
||||
fs.mkdirSync(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user