-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
46 lines (38 loc) · 1.18 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
const gulp = require('gulp');
const del = require('del');
const { spawn } = require('child_process');
function clean () {
return del('lib');
}
function build () {
return spawn('npx tsc -p tsconfig.json', { stdio: 'inherit', shell: true });
}
function lint (options) {
const eslint = require('gulp-eslint');
return gulp
.src([
'src/**/*.js',
'src/**/*.ts',
'test/**/*.js',
'Gulpfile.js',
])
.pipe(eslint(options))
.pipe(eslint.format())
.pipe(options && options.fix ? gulp.dest(file => file.base) : eslint.failAfterError())
.pipe(eslint.failAfterError());
}
function lintFix () {
return lint({ fix: true });
}
function testMocha () {
const mochaOpts = [
'test/**/*test.js',
];
return spawn(`npx mocha ${mochaOpts.join(' ')}`, { stdio: 'inherit', shell: true });
}
exports['fast-build'] = gulp.series(clean, build);
exports.build = gulp.parallel(gulp.series(clean, build), lint);
exports.lint = lint;
exports['lint-fix'] = lintFix;
exports.test = gulp.series(exports.build, testMocha);
exports.default = exports.build;