-
Notifications
You must be signed in to change notification settings - Fork 45
/
gulpfile.js
88 lines (77 loc) · 2.61 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*global require*/
(function () {
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
clean = require('gulp-clean'),
exec = require('gulp-exec'),
plato = require('gulp-plato');
gulp.task('lint', function () {
gulp.src(['./lib/*', './test/*', './gulpfile.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'));
});
gulp.task('istanbul', function (callback) {
gulp.src('./lib/*.js')
.pipe(istanbul())
.on('end', callback);
});
gulp.task('test', function () {
gulp.src('./test/*.js').pipe(mocha({
reporter: 'spec',
bail: true,
ui: 'bdd'
}));
});
gulp.task('test-coverage', function () {
gulp.run('istanbul', function () {
gulp.src('./test/*.js')
.pipe(mocha())
.pipe(istanbul.writeReports())
.pipe(exec('echo Coverage has been calculated. See coverage directory for details.'));
});
});
gulp.task('code-report', function () {
gulp.src('./lib/*.js')
.pipe(plato('./report'))
.pipe(exec('echo The code report has been generated. See report directory for details.'));
});
gulp.task('reports', function () {
gulp.run('test-coverage', 'code-report');
});
gulp.task('clean-reports', function () {
gulp.src(['./coverage', './report'], {
read: false
})
.pipe(clean({
force: true
}));
gulp.src('').pipe(exec('echo Coverage ^& Report directories has been removed'));
});
gulp.task('dev', function () {
gulp.run('lint', 'test');
gulp.watch(['./lib/*', './test/*'], function () {
gulp.run('lint', 'test');
});
});
// gulp.task('prod', function () {
// if (gulp.env.major) {
// gulp.run('lint', 'test');
// gulp.src('./package.json')
// .pipe(mversion('major'))
// .pipe(gulp.dest('./'));
// } else if (gulp.env.minor) {
// gulp.run('lint', 'test');
// gulp.src('./package.json')
// .pipe(mversion('minor'))
// .pipe(gulp.dest('./'));
// } else if (gulp.env.patch) {
// gulp.run('lint', 'test');
// gulp.src('./package.json')
// .pipe(mversion('patch'))
// .pipe(gulp.dest('./'));
// }
// });
}());