This repository was archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
71 lines (62 loc) · 2.2 KB
/
gulpfile.js
File metadata and controls
71 lines (62 loc) · 2.2 KB
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 gulpif = require('gulp-if');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');
var less = require('gulp-less');
var minifyCss = require('gulp-minify-css');
var istanbul = require('gulp-istanbul');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var production = process.env.NODE_ENV === 'production';
var allJavaScriptFiles = ['client/src/**/*.js', 'client/test/**/*.js', 'server/src/**/*.js', 'server/test/**/*.js', '*.js'];
var istanbulReporters = production ? ['text'] : ['text-summary', 'lcov'];
var mochaReporter = production ? 'spec' : 'nyan';
var clientBundleLocation = 'client/bundle';
gulp.task('test', function (callback) {
gulp.src(['client/test/**/*.js', 'server/test/**/*.js'])
.pipe(istanbul({ includeUntested: true }))
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(['client/test/**/*.js', 'server/test/**/*.js'])
.pipe(mocha({ reporter: mochaReporter }))
.pipe(istanbul.writeReports({ reporters: istanbulReporters }))
.pipe(istanbul.enforceThresholds({
thresholds: {
global: 85
}
}))
.on('end', callback);
});
});
gulp.task('lint', function() {
return gulp.src(allJavaScriptFiles)
.pipe(jshint({
esversion: 6
}))
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('scripts', function() {
return gulp.src(['client/lib/*.js', 'client/src/*.js'])
.pipe(concat('app.js'))
.pipe(gulpif(production, uglify()))
.pipe(gulp.dest(clientBundleLocation));
});
gulp.task('less', function() {
return gulp.src('client/less/style.less')
.pipe(less())
.pipe(gulpif(production, minifyCss()))
.pipe(gulp.dest(clientBundleLocation));
});
gulp.task('static', function() {
return gulp.src('client/static/**/*')
.pipe(gulp.dest(clientBundleLocation));
});
gulp.task('watch', function() {
watchMode = true;
gulp.watch(allJavaScriptFiles, ['test', 'lint']);
gulp.watch('client/less/**/*.less', ['less']);
gulp.watch('client/src/**/*.js', ['scripts']);
});
gulp.task('quality', ['test', 'lint']);
gulp.task('default', ['quality', 'scripts', 'less', 'static']);