         @refreshFolder @nodes[nextPath], =>
           callback?()
         return
- 
-      @expandFolder @nodes[nextPath], => 
+
+      @expandFolder @nodes[nextPath], =>
         lastPath = nextPath
         _expand path
 
     _expand path
 
   confirmDelete:(nodeView, event)->
-    
+
     if @selectedNodes.length > 1
-      new NFinderDeleteDialog {}, 
+      new NFinderDeleteDialog {},
         items     : @selectedNodes
         callback  : (confirmation)=>
           @deleteFiles @selectedNodes if confirmation

      folder.emit "fs.compile.finished"
      @notify "App compiled!", "success"
      callback?()
      @utils.wait 500, => 
        @refreshFolder nodeView, =>
          @utils.wait =>
            @selectNode @nodes["#{folder.path}/index.js"]
      
  publishApp:(nodeView)->
    
    folder               = nodeView.getData()
    name                 = FSHelper.trimExtension folder.path
    kodingAppsController = @getSingleton('kodingAppsController')
    kiteController       = @getSingleton('kiteController')

    folder.emit "fs.publish.started"
    
    kodingAppsController.getApp name, (appScript)=>
      
      log "got the app", name
      manifest    = KodingAppsController.apps[name]
      {nickname}  = KD.whoami().profile
      publishPath = FSHelper.escapeFilePath "/opt/Apps/#{nickname}/#{manifest.name}/#{manifest.version}"
      
      log "trying to publish"
      log options = 
        toDo          : "publishApp"
        withArgs      :
          version     : manifest.version
          appName     : manifest.name
          userAppPath : "#{folder.path}/index.js"
      
      kiteController.run options, (err, res)=>
        log "publish finished", err, res
        if err then warn err

    #     else
    #       @expandFolder @nodes[parentPath], =>
    #         @selectNode @nodes[path]

    # file.on "fs.remotefile.created", (oldPath)=>
    #   tc = @treeController
    #   parentNode = tc.nodes[file.parentPath]
    #
    #   if parentNode
    #     if parentNode.expanded
    #       tc.refreshFolder tc.nodes[file.parentPath], ->
