     libraries  = clibraries
 
     @middleware @options, {libraries, kdjs}, (err,finalCode)=>
-      fs.writeFile @options.js, finalCode, (err) => 
+      fs.writeFile @options.js, finalCode, (err) =>
         log.info "Client code is re-compiled and saved."
         callback? null
 

        st = "https://api.koding.com"  # CHANGE THIS TO SOMETHING THAT MAKES SENSE tbd
        index = index.replace ///#{st}///g,""
        log.warn "Static files will be served from NodeJS process. (because -d vpn is used - ONLY DEVS should do this.)"
      fs.writeFile @options.index,index,(err) -> 
        throw err if err
        unless err 
          log.info "Index.html is ready."
          if require("os").platform() is 'linux'
            exec "notify-send \"Koding instance updated\""

module.exports = class Builder

  constructor:(@options,@middleware,fileList="deprecated")->
    # exec """grep "^class " client/Framework/* -R | awk '{split($0,a,":"); split(a[2], b, " "); print "KD.classes[\\""b[2]"\\"]="b[2];}' | uniq > ./client/Framework/classregistry.coffee"""
    exec """grep "^class " client/Framework/* -R | awk '{split($0,a,":"); split(a[2], b, " "); print "KD.classes."b[2]"="b[2];}' | uniq > ./client/Framework/classregistry.coffee"""

    @watcher = new Watcher @options.includesFile

    @attachListeners()

  attachListeners:()->

      # rebuild changes,options

  build:(options)->

  # uglify:(options,callback)->
  #   ast         = parser.parse(options.js)
  #   ast         = uglify.ast_mangle(ast,{no_functions : options.noMangleFunctions}) if options.mangle
  #   ast         = uglify.ast_squeeze(ast) if options.squeeze
  #   final_code  = uglify.gen_code ast,beautify:options.beautify
  #   return final_code

  resetWatcher:()->
    @watcher = new Watcher @options.includesFile

  # buildApplications:(installedAppsPath, builtJsPath)->
  #   buildPath = fs.realpathSync builtJsPath
  #
  #   installedApps = require installedAppsPath
  #   for appName, appPath of installedApps
  #     do (buildPath, appName, appPath)->
  #       path.exists "#{buildPath}/#{appName}", (exists)->
  #         unless exists
  #           fs.mkdirSync "#{buildPath}/#{appName}", 511
  #         exec "cd #{appPath} && cake -p #{buildPath}/#{appName} build", (err)->
  #           log.info "Application #{appName} built, with result", arguments

  buildClient:(options,callback)->

    moduleDeclaration = @watcher.createModuleDeclarations "Client","Framework"

    clibraries  = @watcher.getSubSectionConcatenated "Client","Libraries"

    cclient = ''
    cclient += if options.pistachios then 'PISTACHIO_MODE = "production";' else ''

    cclient += @watcher.getSubSectionConcatenated "Client","Framework"
    cclient += @watcher.getSubSectionConcatenated "Client","Application"
    cclient += @watcher.getSubSectionConcatenated "Client","Applications"
