timestring/Gulpfile.js

66 lines
1.5 KiB
JavaScript
Raw Normal View History

2015-04-30 12:37:57 +02:00
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({
scope: 'devDependencies'
});
2015-04-30 18:03:33 +02:00
2015-04-30 12:37:57 +02:00
var runSequence = require('run-sequence');
2015-04-30 18:03:33 +02:00
var del = require('del');
2015-04-30 12:37:57 +02:00
2015-04-30 18:03:33 +02:00
gulp.task('static-analysis:lint', function () {
2015-04-30 12:37:57 +02:00
gulp.src('src/**/*.js')
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('jshint-stylish'));
});
2015-04-30 18:03:33 +02:00
gulp.task('static-analysis:cs', function () {
2015-04-30 12:37:57 +02:00
return gulp.src('src/**/*.js')
.pipe($.jscs());
});
gulp.task('test', function () {
return gulp.src('test/**/*.js', { read: false })
.pipe($.mocha());
});
2015-04-30 18:03:33 +02:00
gulp.task('build:clean', function (callback) {
del(['build/**/*'], callback);
});
gulp.task('build:copy-src-to-build', function () {
return gulp.src('src/**/*.js')
.pipe(gulp.dest('build'));
});
gulp.task('build:copy-build-to-dist', function () {
return gulp.src('build/**/*.js')
.pipe(gulp.dest('dist'));
});
gulp.task('build:minify', function () {
return gulp.src('build/**/*.js')
2015-04-30 12:37:57 +02:00
.pipe($.sourcemaps.init())
.pipe($.uglify())
.pipe($.rename({
extname: '.min.js'
}))
.pipe($.sourcemaps.write())
.pipe(gulp.dest('dist'));
});
gulp.task('build', function (callback) {
runSequence(
2015-04-30 18:03:33 +02:00
['static-analysis:lint', 'static-analysis:cs', 'test'],
'build:clean',
'build:copy-src-to-build',
'build:copy-build-to-dist',
'build:minify',
2015-04-30 12:37:57 +02:00
callback
);
});
2015-04-30 18:03:33 +02:00
gulp.task('sa', ['static-analysis:lint', 'static-analysis:cs']);
gulp.task('ci', ['static-analysis:lint', 'static-analysis:cs', 'test']);
2015-04-30 12:37:57 +02:00
gulp.task('default', ['build']);