           # @writeCache newFile,(err)->
           callback file, newFile
       else
-        # console.log "reading"+file.path
-        fs.readFile file.cachePath,'utf8',(err,data)->
+        queue.push
+          path      : file.cachePath
+          encoding  : 'utf8'
+        , (err, data) ->
           # console.log 'serving from cache',file.cachePath
           file.lastCompile = Date.now()
           file.contents = data

ProgressBar     = require './node_modules/progress'
#{parser, uglify}  = require "uglify-js"
hat             = require "./node_modules/hat"
# {postProcess}   = require "pistachio-compiler"
# qfunction      = require 'qfunction'

class Watcher extends EventEmitter
  constructor:(filelistPath)->

        console.log err
  compileFile: (file, options, callback)->
    ext = file.path.split(".").pop()

    queue.push
      path     : file.path
      encoding : 'utf8'
    , (err, newContent) =>

      switch ext
        when "styl"
          stylus(newContent).set('compress',true).use(nib()).render (err,css)=>
            unless err
              file.contents = css
              writeCacheFile file.path,css
              callback file
            else
              log.info "error with styl file at #{file.path}"
        when "coffee"
          try
            file.contentsCs = newContent
            # if file.section is "Client"
            #   file.contents = postProcess source:(cs.compile newContent,bare:yes)
            #   # log.debug file.contents
            # else
            file.contents = cs.compile newContent,bare:yes
            writeCacheFile file.path,file.contents



            #file.contents = @uglify js:file.contents,mangle:no,noMangleFunctions:yes,squeeze:no #,beautify:beautify
          catch error
            errd = yes
            log.error "#{(error.stack.split "\n")[0]} at: #{file.path}"
            @emit "CoffeeScript Compile Error",file.path,(error.stack.split "\n")[0]


          callback file
          @emit "coffeeFileContents",file # for sourceCodeAnalyzer.
        else
          file.contents = newContent
          callback file

module.exports  = Watcher
