 #
 # External tasks called by various people (devs, testers, Travis, production)
 #
-
+# TODO: Add this to webpack
 gulp.task 'lint', ->
   gulp.src(['./src/**/*.{cjsx,coffee}', './*.coffee', './test/**/*.{cjsx,coffee}'])
   .pipe(coffeelint())

  .pipe(coffeelint.reporter())
  .pipe(coffeelint.reporter('fail'))

# gulp.task 'dist', ['_build']
gulp.task 'prod', ['_archive']

gulp.task 'serve', ['_buildJS', '_styles', '_webserver']

gulp.task 'test', ['lint'], (done) ->
  buildAndTest(false, done)
  return # Since this is async

gulp.task 'dev', ['_watchLint', '_styles', '_webserver'], ->
  gulp.watch 'resources/styles/**/{*.less, *.css}', ['_css']
  build(true)

gulp.task 'tdd', ['_styles', '_tdd', '_webserver'], ->
  gulp.watch 'resources/styles/**/{*.less, *.css}', ['_css']
  gulp.watch ['test/**/*.coffee'], ['_tdd']

  gulp.watch '*.coffee', ['lint']


gulp.task '_karma', ->
  server = new karma.Server(KARMA_CONFIG)
  server.start()


gulp.task '_webserver', ->
  config = _.extend( {}, webpackConfig, {
    devtool: 'source-map'
    debug: true
    output:
      path: '/'
      filename: 'tutor.js'
      pubicPath: '/dist/'
  })
  new webpackServer(webpack(config), config.devServer)
  .listen(webpackConfig.devServer.port, 'localhost', (err) ->
    throw new gutil.PluginError("webpack-dev-server", err) if err
  )


# -----------------------------------------------------------------------
