UNPKG

2.8 kBJavaScriptView Raw
1var gulp = require('gulp'),
2 coveralls = require('gulp-coveralls'),
3 eslint = require('gulp-eslint'),
4 jscs = require('gulp-jscs'),
5 istanbul = require('gulp-istanbul'),
6 mocha = require('gulp-mocha'),
7 publish = require('gulp-gh-pages');
8
9var paths = {
10 src: ['./lib/**/*.js'],
11 testUnit: './test/unit/*.js',
12 testFunc: './test/functional/*.js',
13 site: ['./site/**/*']
14};
15paths.test = [].concat(paths.testUnit, paths.testFunc);
16
17gulp.task('jscs', function () {
18 gulp.src(paths.src
19 .concat(paths.test))
20 .pipe(jscs());
21});
22
23// lints javascript files with eslint
24// edit .eslintrc for configuration
25gulp.task('lint', ['jscs'], function () {
26 return gulp.src(paths.src
27 .concat(paths.test)
28 .concat('./gulpfile.js'))
29 .pipe(eslint())
30 .pipe(eslint.format());
31});
32
33// instruments js source code for coverage reporting
34gulp.task('istanbul', function (done) {
35 gulp.src(paths.src)
36 .pipe(istanbul())
37 .on('finish', done);
38});
39
40// runs mocha tests
41gulp.task('test', ['istanbul'], function (done) {
42 // expose globals here for now
43 // move these into their own file if they grow
44 global.chai = require('chai');
45 global.expect = global.chai.expect;
46
47 gulp.src(paths.test, {read:false})
48 .pipe(mocha({
49 reporter: 'list'
50 }))
51 .pipe(istanbul.writeReports())
52 .on('end', done);
53});
54
55// plato report
56// TODO: think bout this a bit more
57gulp.task('plato', function () {
58 var plato = require('gulp-plato');
59 gulp.src(paths.src)
60 .pipe(plato('report', {}));
61});
62
63// jsdoc generation
64gulp.task('jsdoc', function () {
65 var jsdoc = require('gulp-jsdoc');
66 gulp.src(paths.src.concat('README.md'))
67 .pipe(jsdoc.parser({
68 plugins: [
69 'plugins/escapeHtml',
70 'plugins/markdown'
71 ],
72 markdown: {
73 parser: 'gfm',
74 githubRepoOwner: 'htmllint',
75 githubRepoName: 'htmllint'
76 }
77 }))
78 .pipe(jsdoc.generator('./site/api', {
79 // template
80 path: 'ink-docstrap',
81 theme: 'cerulean',
82 systemName: 'htmllint',
83 navType: 'vertical',
84 linenums: true,
85 inverseNav: true,
86 outputSourceFiles: true
87 }));
88});
89
90gulp.task('doc:gen', ['jsdoc']);
91
92gulp.task('doc:pub', ['doc:gen'], function () {
93 gulp.src(paths.site)
94 .pipe(publish({
95 cacheDir: '.tmp'
96 }));
97});
98
99// runs on travis ci (lints, tests, and uploads to coveralls)
100gulp.task('travis', ['lint', 'test'], function () {
101 gulp.src('coverage/**/lcov.info')
102 .pipe(coveralls());
103});
104
105gulp.task('default', [
106 'lint',
107 'test'
108]);