         logger.info "compiled."
         logger.debug "compilation time: #{Date.now() - @start}ms"
         @watcher.close() unless @persistent
-        @onCompile null, result
+        @onCompile result
 
   watch: ->
     @initServer()

    , []

class BrunchWatcher
  constructor: (@persistent, @options, @onCompile) ->
    params = {}
    params.minify = yes if options.minify
    if persistent
      params.server = {}
      params.server.run = yes if options.server

        .on('unlink', @removeFromFileList)
        .on('error', logger.error)

  onCompile: (result) =>
    @_onCompile result
    @plugins
      .filter (plugin) ->
        typeof plugin.onCompile is 'function'
      .forEach (plugin) ->
        plugin.onCompile result

  compile: =>
    paths = @config.paths
    fs_utils.write @fileList, @config, @plugins, (error, result) =>
