-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
51 lines (42 loc) · 1.23 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
const gulp = require('gulp');
// ES6 JS/JSX Lineter -- Check for syntax errors
const eslint = require('gulp-eslint');
// Test Framework
const mocha = require('gulp-mocha');
// Prettifying
const prettier = require('gulp-prettier');
const prettyConf = require('./.prettierrc.json');
const testFolder = 'test';
const allJSFiles = ['*.js', `${testFolder}/**/*.js`, `${testFolder}/*.js`];
const esLintOpts = { configFile: '.eslintrc.json', fix: true };
// Lint JS Files
gulp.task('lint', () => {
return gulp
.src(allJSFiles)
.pipe(eslint({ configFile: '.eslintrc.json' }))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('test', () => {
return gulp.src('test/*.js', { read: false })
.pipe(mocha())
.once('error', () => {
process.exit(1);
});
});
gulp.task('fix', () => {
return gulp.src(allJSFiles).pipe(eslint(esLintOpts))
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(gulp.dest((file) => {
return file.base;
}));
});
gulp.task('pretty', () => {
return gulp.src(allJSFiles).pipe(prettier(prettyConf))
.pipe(eslint(esLintOpts))
.pipe(gulp.dest((file) => {
return file.base;
}));
});
gulp.task('default', gulp.series('lint', 'test'));