forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (55 loc) · 1.45 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
/* eslint max-nested-callbacks: 0 */
const eslint = require('gulp-eslint');
const { exec } = require('child_process');
const gulp = require('gulp');
const jsonEditor = require('gulp-json-editor');
const path = require('path');
function execCb(cb, err, stdout, stderr) {
console.log(stdout);
console.error(stderr);
cb(err);
}
const options = {
coveragePaths: [
'*.js',
'packages/**/*.js',
'!packages/**/test/*.js',
'!packages/**/test/**/*.js',
'!packages/**/static/*.js'
],
lintPaths: [
'*.js',
'packages/**/*.js',
'!packages/**/static/*.js'
],
nodeBin: path.resolve(__dirname, './packages/jsdoc/jsdoc.js'),
nodePath: process.execPath
};
function bump(cb) {
gulp.src('./package.json')
.pipe(jsonEditor({
revision: String( Date.now() )
}))
.pipe(gulp.dest('./'));
cb();
}
function coverage(cb) {
const cmd = `./node_modules/.bin/nyc --reporter=html ${options.nodeBin} -T`;
exec(cmd, execCb.bind(null, cb));
}
function lint(cb) {
gulp.src(options.lintPaths)
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.failOnError());
cb();
}
function test(cb) {
const cmd = `${options.nodePath} "${options.nodeBin}" -T`;
exec(cmd, execCb.bind(null, cb));
}
exports.bump = bump;
exports.coverage = coverage;
exports.default = gulp.series(lint, test);
exports.lint = lint;
exports.test = test;