-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgulpfile.js
115 lines (92 loc) · 2.2 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
'use strict';
/**
* Gulp dependencies.
*/
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
/**
* Build variables.
*/
var paths = {
src: ['lib/**/*.js'],
spec: ['test/**/*.spec.js'],
js: ['lib/**/*.js', 'test/**/*.js']
};
/**
* Helpers functions.
*/
var open = function(path) {
return plugins.shell.task([
'echo Opening ' + path,
'open ' + path
]);
};
/**
* Linting on source and tests.
*/
gulp.task('lint', function() {
return gulp.src(paths.js.concat('gulpfile.js'))
.pipe(plugins.jshint())
.pipe(plugins.count('Linted (' + paths.js + ') ## files'))
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
});
/**
* Run mocha tests and istanbul coverage report.
*/
gulp.task('test', ['lint'], function(cb) {
var istanbul = plugins.istanbul;
gulp.src(paths.src)
.pipe(istanbul({
dir: './coverage',
reporters: [ 'lcov', 'json', 'text', 'text-summary', 'clover' ],
reportOpts: { dir: './coverage' }
}))
.pipe(istanbul.hookRequire())
.on('finish', function () {
return gulp.src(paths.spec)
.pipe(plugins.mocha({
reporter: 'spec',
require: ['./test/helpers/chai']
}))
.pipe(istanbul.writeReports({
reporters: [
'lcov',
'json',
'text',
'text-summary',
'clover'
]
}))
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) // Enforce a coverage of at least 90%
.on('end', cb);
});
});
/**
* Open coverage report.
*/
gulp.task('coverage', ['test'], open('coverage/lcov-report/index.html'));
/**
* Create docco documentation.
*/
gulp.task('docs', ['test'], function() {
gulp.src(paths.src)
.pipe(plugins.docco({
layout: 'classic'
}))
.pipe(gulp.dest('./docs/docco'));
});
/**
* Open coverage report.
*/
gulp.task('docs.open', ['docs'], open('docs/docco/index.html'));
/**
* Watch source code and run default tasks.
*/
gulp.task('watch', ['default'], function() {
gulp.watch(paths.js.concat(paths.spec), ['default']);
});
/**
* Default tasks.
*/
gulp.task('default', ['lint','test']);