var gulp = require('gulp')
require('traceur/bin/traceur-runtime')
var $ = require('gulp-load-plugins')({
    lazy: true
});


gulp.task('default', ['serve-dev'])

gulp.task('test', ['build'], function () {
    return gulp.src('build/**/*Spec.js', {
            read: false
        })
        .pipe($.mocha({
            reporter: 'nyan'
        }))
})

gulp.task('serve-dev', ['build'], function () {
    serve(true)
})

gulp.task('serve-build', ['build'], function () {
    serve(false)
})

gulp.task('clean', function () {
    return gulp.src('build', {
            read: false
        })
        .pipe($.clean())
})

gulp.task('build', ['clean'], function () {
    gulp.src('src/views/**')
        .pipe(gulp.dest('build/views/'));

    return gulp.src('src/**/*.js')
        .pipe($.sourcemaps.init())
        .pipe($.traceur({annotations:true, types:true, typeAssertions:true, typeAssertionModule:'../assert'}))
        .pipe($.sourcemaps.write('.'))
        .pipe(gulp.dest('build'))
})

gulp.task('test', ['build'], function () {
    return gulp.src('build/**/*Spec.js', {
            read: false
        })
        .pipe($.mocha({
            reporter: 'nyan'
        }))
})

function serve(isDev) {
    require('./build')

    var debug = true //args.debug || args.debugBrk

    if (debug) {
        var exec = require('child_process').exec
        exec('node-inspector')
    }
}

@@ -1134,48 +1134,8 @@
 cha(
-%7B%0A            reporter: 'nyan'%0A        %7D
 ))%0A%7D

Remove nyan Mocha reporter to show better results in Travis CI