-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
63 lines (53 loc) · 1.52 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
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 config = require('./build.config');
const prettyConf = require('./.prettierrc.json');
const devFolder = config.devFolder;
const testFolder = config.testFolder;
const configFolder = config.configFolder;
const scriptsFolder = config.scriptsFolder;
const allJSFiles = [
'*.js',
`${testFolder}/**/*.js`,
`${testFolder}/*.js`,
`${devFolder}/**/*.js`,
`${devFolder}/*.js`,
`${configFolder}/*.js`,
`${scriptsFolder}/*.js`
];
const esLintOpts = { configFile: '.eslintrc.json', fix: true };
// Lint JS/JSX Files (For Express)
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'));