 dialog = require 'dialog'
 
 class AtomApplication
+  resourcePath: null
   windowState: null
   menu: null
   windows: null
 
-  constructor: ->
+  constructor: (@resourcePath) ->
+    @resourcePath ?= path.dirname(__dirname)
     @windowState = {}
     @windows = []
 

  createAtomWindow: ->
    new AtomWindow
      bootstrapScript: 'window-bootstrap',
      resourcePath: resourcePath

class AtomWindow
  bootstrapScript: null
  resourcePath: null

  constructor: ({@bootstrapScript, @resourcePath}) ->
    @resourcePath ?= path.dirname(__dirname)
    @window = @open()

    @window.on 'close', (event) =>

bootstrapApplication = ->
  parseCommandLine()
  setupNodePath()
  atomApplication = new AtomApplication(resourcePath)
  atomApplication.createAtomWindow()

delegate.browserMainParts.preMainMessageLoopRun = bootstrapApplication
