-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
71 lines (64 loc) · 2.08 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var templateCache = require('gulp-angular-templatecache');
var istanbul = require('gulp-istanbul');
gulp.task('mocha', function() {
process.env.NODE_ENV = 'test';
gulp.src(['./api/**/*.js', '!./api/**/*.spec.js', '!./api/index.js', '!./api/lib/**/*.js'])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', function() {
gulp.src('./api/**/*.spec.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec'
}))
.pipe(istanbul.writeReports({
reporters: ['html', 'text', 'text-summary', 'lcov']
}))
.pipe(istanbul.enforceThresholds({
thresholds: {
global: 80
}
}))
.once('end', function() {
process.exit();
});
});
});
gulp.task('templates', function() {
return gulp.src('./app/js/**/*.html')
.pipe(templateCache({module: 'Scholar', root: 'app'}))
.pipe(gulp.dest('./app/js/tmp/'))
});
gulp.task('build-js', ['templates'], function() {
return gulp.src([
'./node_modules/lazysizes/lazysizes.min.js',
'./app/js/**/*.js'
])
.pipe(concat('bundle.js'))
.pipe(uglify().on('error', console.log.bind(this)))
.pipe(gulp.dest('./public/js/'));
});
gulp.task('build-css', ['sass'], function() {
return gulp.src(['./app/tmp/**/*.css', './app/js/**/*.css'])
.pipe(concat('bundle.css'))
.pipe(gulp.dest('./public/css/'));
});
gulp.task('sass', function() {
return gulp.src('./app/sass/style.scss')
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(gulp.dest('./app/tmp/'));
});
gulp.task('watch', ['build-css', 'build-js'], function() {
gulp.watch(['./app/sass/**/*.scss'], ['build-css']);
gulp.watch(['./app/js/**/*.js'], ['build-js']);
gulp.watch(['./app/**/*.html'], ['build-js']);
});
gulp.task('default', ['watch']);
gulp.task('test', ['mocha']);