forked from DAVFoundation/missioncontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
77 lines (67 loc) · 1.87 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
74
75
76
77
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const shell = require('gulp-shell');
const nodemon = require('gulp-nodemon');
const path = require('path');
const jest = require('jest-cli');
const jestConfig = {
verbose: false,
rootDir: '.'
};
gulp.task('lint', () => {
return gulp.src(['**/*.js', '!node_modules/**', '!server/thrift/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('jest', (done) => {
jest.runCLI({
config: Object.assign(jestConfig, { testMatch: ['**/test/specs/*.js'] })
}, '.', () => done());
});
gulp.task('jest:thrift', (done) => {
jest.runCLI({
config: Object.assign(jestConfig, { testMatch: ['**/test/specs/thrift/*.js'] })
}, '.', () => done());
});
gulp.task('thrift-build', shell.task('npm run thrift'));
gulp.task('watch', ['js', 'thrift'], () =>
nodemon({
script: 'server/start-servers.js',
ext: 'js thrift',
watch: ['server', 'test', 'resources/idl'],
ignore: [
'server/thrift',
'node_modules/'
],
tasks: (changedFiles) => {
let tasks = [];
changedFiles.forEach(file => {
if (path.extname(file) === '.js' && !tasks.includes('js')) tasks.push('js');
if (path.extname(file) === '.thrift' && !tasks.includes('thrift')) tasks.push('thrift');
});
return tasks;
}
})
);
gulp.task('watch:js', ['js'], () =>
nodemon({
script: 'server/start-server-web.js',
ext: 'js',
watch: ['server', 'test'],
ignore: [
'server/thrift',
'node_modules/'
],
tasks: (changedFiles) => {
let tasks = [];
changedFiles.forEach(file => {
if (path.extname(file) === '.js' && !tasks.includes('js')) tasks.push('js');
});
return tasks;
}
})
);
gulp.task('js', ['lint', 'jest']);
gulp.task('thrift', ['thrift-build']);
gulp.task('default', ['thrift', 'js']);