 mocha = require 'gulp-mocha'
 sourcemaps = require 'gulp-sourcemaps'
 
-onError = (e) ->
-  gutil.log e
-  @emit 'end'
+ignoreError = (stream) ->
+  stream.on 'error', (e) ->
+    gutil.log e
+    @emit 'end'
 
 gulp.task 'build', ->
   gulp.src './src/*'

gulp.task 'build-dev', ->
  gulp.src './src/*'
    .pipe sourcemaps.init()
    .pipe babel(modules: 'umd').on 'error', onError
    .pipe sourcemaps.write()
    .pipe gulp.dest './dist/'


gulp.task 'build-test-dev', ->
  gulp.src './test/*'
    .pipe sourcemaps.init()
    .pipe ignoreError coffee()
    .pipe ignoreError espower()
    .pipe sourcemaps.write()
    .pipe gulp.dest './.tmp/'

