2016-10-14 12:32:53 +02:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var concat = require('gulp-concat');
|
|
|
|
var sort = require('gulp-sort');
|
|
|
|
var minify = require('gulp-minify');
|
2016-10-18 13:37:38 +02:00
|
|
|
var plumber = require('gulp-plumber');
|
|
|
|
var istanbul = require('gulp-istanbul');
|
|
|
|
var mocha = require('gulp-mocha');
|
2016-10-14 12:32:53 +02:00
|
|
|
|
|
|
|
gulp.task(
|
|
|
|
'build',
|
|
|
|
function() {
|
|
|
|
return gulp.src('./src/game-lib-*.js')
|
|
|
|
.pipe(sort())
|
|
|
|
.pipe(concat('game-lib.js'))
|
|
|
|
.pipe(minify({
|
|
|
|
ext:{
|
2016-10-14 13:08:22 +02:00
|
|
|
src:'.js',
|
|
|
|
min:'-min.js'
|
2016-10-14 12:32:53 +02:00
|
|
|
}
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./build/'));
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-10-18 13:37:38 +02:00
|
|
|
gulp.task('test-prepare', function(){
|
2016-10-18 13:49:03 +02:00
|
|
|
return gulp.src('./build/game-lib.js')
|
2016-10-18 13:37:38 +02:00
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(istanbul())
|
|
|
|
.pipe(istanbul.hookRequire())
|
|
|
|
.on('end', function(){
|
|
|
|
console.log('prepared the game lib for code coverage');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task(
|
|
|
|
'test',
|
|
|
|
['build', 'test-prepare'],
|
|
|
|
function() {
|
|
|
|
gulp.src('./test/test.*.js')
|
|
|
|
.pipe(sort())
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(mocha({reporter: 'spec'}))
|
2016-10-18 13:49:03 +02:00
|
|
|
.pipe(istanbul.writeReports({
|
|
|
|
dir: './build/coverage',
|
|
|
|
reporters: [ 'lcov' ],
|
|
|
|
reportOpts: { dir: './build/coverage' }
|
|
|
|
}))
|
2016-10-18 13:37:38 +02:00
|
|
|
.pipe(istanbul.enforceThresholds({thresholds:{global:90}}))
|
|
|
|
.on('error',
|
|
|
|
function(error) {
|
|
|
|
console.log('plugin error occurred' + error);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.on('end',
|
|
|
|
function() {
|
|
|
|
console.log('test task ended')
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-10-14 12:32:53 +02:00
|
|
|
gulp.task(
|
|
|
|
'default',
|
|
|
|
['build'],
|
|
|
|
function() {}
|
|
|
|
);
|