forked from htmllint/htmllint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
110 lines (98 loc) · 2.82 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
var gulp = require('gulp'),
coveralls = require('gulp-coveralls'),
eslint = require('gulp-eslint'),
jscs = require('gulp-jscs'),
istanbul = require('gulp-istanbul'),
mocha = require('gulp-mocha'),
publish = require('gulp-gh-pages');
var paths = {
src: ['./lib/**/*.js'],
testUnit: './test/unit/*.js',
testFunc: './test/functional/*.js',
site: ['./site/**/*']
};
paths.test = [].concat(paths.testUnit, paths.testFunc);
gulp.task('jscs', function () {
gulp.src(paths.src
.concat(paths.test))
.pipe(jscs());
});
// lints javascript files with eslint
// edit .eslintrc for configuration
gulp.task('lint', ['jscs'], function () {
return gulp.src(paths.src
.concat(paths.test)
.concat('./gulpfile.js'))
.pipe(eslint())
.pipe(eslint.format());
});
// instruments js source code for coverage reporting
gulp.task('istanbul', function (done) {
gulp.src(paths.src)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', done);
});
// runs mocha tests
gulp.task('test', ['istanbul'], function (done) {
// expose globals here for now
// move these into their own file if they grow
global.chai = require('chai');
global.chai.use(require('chai-as-promised'));
global.expect = global.chai.expect;
gulp.src(paths.test, {read:false})
.pipe(mocha({
reporter: 'list'
}))
.pipe(istanbul.writeReports())
.on('end', done);
});
// plato report
// TODO: think bout this a bit more
gulp.task('plato', function () {
var plato = require('plato');
gulp.src(paths.src)
.pipe(plato('report', {}));
});
// jsdoc generation
gulp.task('jsdoc', function () {
var jsdoc = require('gulp-jsdoc');
gulp.src(paths.src.concat('README.md'))
.pipe(jsdoc.parser({
plugins: [
'plugins/escapeHtml',
'plugins/markdown'
],
markdown: {
parser: 'gfm',
githubRepoOwner: 'htmllint',
githubRepoName: 'htmllint'
}
}))
.pipe(jsdoc.generator('./site/api', {
// template
path: 'ink-docstrap',
theme: 'cerulean',
systemName: 'htmllint',
navType: 'vertical',
linenums: true,
inverseNav: true,
outputSourceFiles: true
}));
});
gulp.task('doc:gen', ['jsdoc']);
gulp.task('doc:pub', ['doc:gen'], function () {
gulp.src(paths.site)
.pipe(publish({
cacheDir: '.tmp'
}));
});
// runs on travis ci (lints, tests, and uploads to coveralls)
gulp.task('travis', ['lint', 'test'], function () {
gulp.src('coverage/**/lcov.info')
.pipe(coveralls());
});
gulp.task('default', [
'lint',
'test'
]);