-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
70 lines (61 loc) · 1.99 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
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
nodemon = require('gulp-nodemon'),
sass = require('gulp-sass'),
karma = require('karma').server,
app;
gulp.task('mocha', function () {
process.env.NODE_ENV = 'development';
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: 85
}
}))
.once('end', function () {
process.exit();
});
});
});
gulp.task('unit', function (done) {
return karma.start({
configFile: __dirname + '/config/karma.conf.js'
}, function () {
done();
});
});
gulp.task('nodemon', function () {
process.env.NODE_ENV = 'development';
nodemon({
script: "./api/server.js",
ignore: ['./api/**/*.spec.js', './public/**/*']
})
.on('restart', function () {
console.log('restarted!');
});
});
gulp.task('sass', function () {
gulp.src('./sass/style.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(gulp.dest('./public/css/'));
});
gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});
gulp.task('watch', function () {
gulp.watch('./api/**/*.js');
});
gulp.task('default', ['nodemon', 'watch', 'sass:watch']);
gulp.task('test', ['mocha']);