'use strict';

var gulp = require('gulp');
var $ = require('gulp-load-plugins')({ pattern: ['gulp-*', 'vinyl-*',
    'del', 'lazypipe', 'browserify', 'babelify', 'karma'] });

var watch = false;

gulp.task('clean', function (cb) {
    $.del(['dist/'], cb);
});

gulp.task('lint', function () {
    return gulp.src(['src/**/*.js', '!node_modules/**', '!bower_components/**'])
        .pipe($.eslint())
        .pipe($.eslint.format())
        .pipe($.eslint.failAfterError());
});

gulp.task('test', function (cb) {
    new $.karma.Server({
        configFile: __dirname + '/karma.conf.js',
        reporters: ['dots'],
        singleRun: true
    }, cb).start();
});

var minify = $.lazypipe()
    .pipe($.sourcemaps.init, { loadMaps: true })
    .pipe($.uglify)
    .pipe($.rename, { extname: '.min.js' })
    .pipe($.sourcemaps.write, '/');

gulp.task('scripts', ['clean'], function () {
    return $.browserify({ entries: ['./src/openseadragon-annotations.js'] })
        .transform($.babelify)
        .bundle()
        .pipe($.vinylSourceStream('openseadragon-annotations.js'))
        .pipe($.vinylBuffer())
        .pipe(gulp.dest('dist'))
        .pipe($.if(!watch, minify()))
        .pipe(gulp.dest('dist'));
});

gulp.task('images', ['clean'], function () {
    return gulp.src('img/**/*.*')
        .pipe(gulp.dest('dist/img'));
});

gulp.task('build', ['lint', 'clean', 'scripts', 'images']);

gulp.task('watch', ['build'], function () {
    watch = true;
    gulp.watch('src/**/*.js', ['lint', 'clean', 'scripts']);
});

gulp.task('default', ['watch']);

@@ -478,195 +478,8 @@
 );%0A%0A
-gulp.task('test', function (cb) %7B%0A    new $.karma.Server(%7B%0A        configFile: __dirname + '/karma.conf.js',%0A        reporters: %5B'dots'%5D,%0A        singleRun: true%0A    %7D, cb).start();%0A%7D);%0A%0A
 var 

Remove gulp 'test' task