       console.log "#{f} updated."
     else
       console.log "#{f} removed."
+    # This is run with a timeout to avoid build spam, such as when moving and
+    # deleting a large amount of files.  The timer is reset whenever a request
+    # is made inside the timeout period.
     clearTimeout exports.watchTimeout if exports.watchTimeoutWaiting
     exports.watchTimeoutWaiting = true
     exports.watchTimeout = setTimeout ->


desc 'Build concatenated source.'
task 'concat', ->
  jake.Task['compile'].invoke()
  console.log 'Concatenating compiled source...'
  jake.exec ["find build/compiled/ -name *.js | xargs cat > #{buildFiles.concatenated}"], ->
    console.log 'Successfully concatenated compiled source.'
    complete()
, {async: true}

desc 'Build minified source.'
task 'minify', ->
  console.log 'Minifying source...'
  concatenated = fs.readFileSync buildFiles.concatenated, 'utf8'
  jsp = uglifyJs.parser

  concatenated: "build/#{config.buildName}-concat.js"
  minified: "build/#{config.buildName}-min.js"

# PACKAGE METHODS AND VARIABLES

# Used to track the watcher timeout, to avoid build spam on mass source changes.
exports.watchTimeout = null
exports.watchTimeoutWaiting = false

# Gets the .js equivalent of a file.  Converts .js.coffe and .coffee to .js.
exports.getJsName = (file) ->
  return file.replace /(\.js)?\.coffee$/, '.js' if file.match /\.coffee$/
  file

# TASKS

