 defaultApiPort = args.apiport or 33400
 args.docsetdir = args.docsetdir or path.join(process.cwd(), "Docsets")
 
-# check if there is already an Slash is running
 mainWindow = null
 
-
 app.on 'ready', ->
+    # check if Slash is running
     new Promise (resolve, reject)->
         fs.readFile path.join(args.profiledir, 'api.port'), (err, data)->
             return reject(err) if err

            setTimeout ->
                resolve()
            , 1000
    .catch ->
        app.quit()
    .then ->
        require('./server/doc-server').run(defaultDocPort, args.docsetdir)
    .then ->

        mainWindow.openDevTools() if args.debug
        mainWindow.loadUrl 'file://' + __dirname + '/../browser/index.html'
app.on 'window-all-closed', ->
    fs.unlinkSync path.join(args.profiledir, 'api.port')
    app.quit()
ipc.on 'showMainWindow', ->
    args.mainWindow.focus()
    args.mainWindow.focusOnWebView()