mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Move task-bootstrap to src/
This commit is contained in:
committed by
probablycorey
parent
bff57e53f0
commit
3f5bee7e4c
37
src/task-bootstrap.coffee
Normal file
37
src/task-bootstrap.coffee
Normal file
@@ -0,0 +1,37 @@
|
||||
{userAgent, taskPath} = process.env
|
||||
handler = null
|
||||
|
||||
setupGlobals = ->
|
||||
global.attachEvent = ->
|
||||
console =
|
||||
warn: -> emit 'task:warn', arguments...
|
||||
log: -> emit 'task:log', arguments...
|
||||
error: -> emit 'task:error', arguments...
|
||||
global.__defineGetter__ 'console', -> console
|
||||
|
||||
global.document =
|
||||
createElement: ->
|
||||
setAttribute: ->
|
||||
getElementsByTagName: -> []
|
||||
appendChild: ->
|
||||
documentElement:
|
||||
insertBefore: ->
|
||||
removeChild: ->
|
||||
getElementById: -> {}
|
||||
createComment: -> {}
|
||||
createDocumentFragment: -> {}
|
||||
|
||||
global.emit = (event, args...) ->
|
||||
process.send({event, args})
|
||||
global.navigator = {userAgent}
|
||||
global.window = global
|
||||
|
||||
handleEvents = ->
|
||||
process.on 'uncaughtException', (error) -> console.error(error.message)
|
||||
process.on 'message', ({args}) ->
|
||||
result = handler(args...)
|
||||
emit('task:completed', result)
|
||||
|
||||
setupGlobals()
|
||||
handleEvents()
|
||||
handler = require(taskPath)
|
||||
Reference in New Issue
Block a user