-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (63 loc) · 1.9 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
'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var noop = function(){};
var paths = {
lint: ['./gulpfile.js'],
watch: ['./gulpfile.js', './lib/**', './test/**/*.js', '!test/{temp,temp/**}'],
tests: ['./test/**/*.js', '!test/{temp,temp/**}'],
source: ['./lib/*.js'],
dest: ['./build']
};
var plumberConf = {};
if (process.env.CI) {
plumberConf.errorHandler = function(err) {
throw err;
};
}
gulp.task('build', function(cb) {
gulp.src(paths.source)
// .pipe(plugins.sourcemaps.init())
// .pipe(plugins.sweetjs({
// modules: ['lambda-jam/macro']
// }))
// .pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('build'))
.on('end', cb)
.on('error', noop);
});
gulp.task('lint', function () {
return gulp.src(paths.lint)
.pipe(plugins.jshint('.jshintrc'))
.pipe(plugins.plumber(plumberConf))
.pipe(plugins.jscs())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.on('error', noop);
});
gulp.task('istanbul', ['build'], function (cb) {
gulp.src(paths.source)
.pipe(plugins.istanbul()) // Covering files
.on('finish', function () {
gulp.src(paths.tests)
.pipe(plugins.plumber(plumberConf))
.pipe(plugins.mocha())
.pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned
.on('finish', function() {
process.chdir(__dirname);
cb();
})
.on('error',noop);
});
});
gulp.task('bump', ['build', 'test'], function () {
var bumpType = plugins.util.env.type || 'patch'; // major.minor.patch
return gulp.src(['./package.json'])
.pipe(plugins.bump({ type: bumpType }))
.pipe(gulp.dest('./'));
});
gulp.task('watch', ['build', 'test'], function () {
gulp.watch(paths.watch, ['build', 'test']);
});
gulp.task('test', ['build', 'istanbul']);
gulp.task('release', ['bump']);
gulp.task('default', ['lint', 'watch']);