+async = require 'async'
+{EventEmitter} = require 'events'
 fs = require 'fs'
 path = require 'path'
-async = require 'async'
-{EventEmitter} = require 'events'
 
 # Function that sorts array.
 # array - array to be sorted.

    unless sourceFile
      sourceFile = changedFile
      concatenated = destFile.sourceFiles.concat [sourceFile]
      destFile.sourceFiles = exports.sort concatenated, @config.files[changedFile.destinationPath].order
      delete changedFile.destinationPath
    sourceFile.data = changedFile.data


  write: =>
    console.log 'Writing files', JSON.stringify @destFiles, null, 2
    async.forEach @destFiles, (destFile, next) =>
      # TODO.
      destPath = path.join 'build', destFile.path
      destIsJS = /\.js$/.test destPath
      data = ''
      data += requireDefinition if destIsJS
      data += destFile.sourceFiles
        .map (sourceFile) ->
          if destIsJS and not (/^vendor/.test sourceFile.path)
            wrap sourceFile.path, sourceFile.data
          else
            sourceFile.data
        .join ''
      fs.writeFile destPath, data, (error) =>
        next error, {path: destPath, data}
    , (error, results) =>
