UNPKG

2.85 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.chai.use(require('chai-as-promised'));
46 global.expect = global.chai.expect;
47
48 gulp.src(paths.test, {read:false})
49 .pipe(mocha({
50 reporter: 'list'
51 }))
52 .pipe(istanbul.writeReports())
53 .on('end', done);
54});
55
56// plato report
57// TODO: think bout this a bit more
58gulp.task('plato', function () {
59 var plato = require('gulp-plato');
60 gulp.src(paths.src)
61 .pipe(plato('report', {}));
62});
63
64// jsdoc generation
65gulp.task('jsdoc', function () {
66 var jsdoc = require('gulp-jsdoc');
67 gulp.src(paths.src.concat('README.md'))
68 .pipe(jsdoc.parser({
69 plugins: [
70 'plugins/escapeHtml',
71 'plugins/markdown'
72 ],
73 markdown: {
74 parser: 'gfm',
75 githubRepoOwner: 'htmllint',
76 githubRepoName: 'htmllint'
77 }
78 }))
79 .pipe(jsdoc.generator('./site/api', {
80 // template
81 path: 'ink-docstrap',
82 theme: 'cerulean',
83 systemName: 'htmllint',
84 navType: 'vertical',
85 linenums: true,
86 inverseNav: true,
87 outputSourceFiles: true
88 }));
89});
90
91gulp.task('doc:gen', ['jsdoc']);
92
93gulp.task('doc:pub', ['doc:gen'], function () {
94 gulp.src(paths.site)
95 .pipe(publish({
96 cacheDir: '.tmp'
97 }));
98});
99
100// runs on travis ci (lints, tests, and uploads to coveralls)
101gulp.task('travis', ['lint', 'test'], function () {
102 gulp.src('coverage/**/lcov.info')
103 .pipe(coveralls());
104});
105
106gulp.task('default', [
107 'lint',
108 'test'
109]);