forked from OutOfSyncStudios/winston-logstash-transport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (63 loc) · 1.69 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
67
68
69
70
71
72
73
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');
// Documentation Generation
const jsdoc = require('gulp-jsdoc3');
const config = require('./build.config');
const prettyConf = require('./.prettierrc.json');
const devFolder = config.devFolder;
const testFolder = config.testFolder;
const docsFolder = config.docsFolder;
const allJSFiles = [
'*.js',
`${testFolder}/**/*.js`,
`${testFolder}/*.js`,
`${devFolder}/**/*.js`,
`${devFolder}/*.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', gulp.series('lint'), () => {
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('docs', (done) => {
gulp
.src(['README.md', `./${devFolder}**/*.js`, `./${config.main}`], { read: false })
.pipe(jsdoc({ opts: { destination: docsFolder } }, done));
});
gulp.task('default', gulp.series('test'));