forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
52 lines (43 loc) · 1.19 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
const eslint = require('gulp-eslint7');
const { exec } = require('child_process');
const gulp = require('gulp');
const path = require('path');
const prettier = require('gulp-prettier');
function execCb(cb, err, stdout, stderr) {
console.log(stdout);
console.error(stderr);
cb(err);
}
const options = {
lintPaths: [
'*.js',
'packages/**/*.js',
'!packages/**/static/*.js',
'!packages/**/test/fixtures/**/*.js',
],
nodeBin: path.resolve(__dirname, './packages/jsdoc/jsdoc.js'),
nodePath: process.execPath,
};
function coverage(cb) {
const cmd = `./node_modules/.bin/nyc --reporter=html ${options.nodeBin} -T`;
return exec(cmd, execCb.bind(null, cb));
}
function format() {
return gulp.src(options.lintPaths, { base: './' }).pipe(prettier()).pipe(gulp.dest('./'));
}
function lint() {
return gulp
.src(options.lintPaths)
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.failAfterError());
}
function test(cb) {
const cmd = `${options.nodePath} "${options.nodeBin}" -T`;
return exec(cmd, execCb.bind(null, cb));
}
exports.coverage = coverage;
exports.default = gulp.series(lint, test);
exports.format = format;
exports.lint = lint;
exports.test = test;