-
Notifications
You must be signed in to change notification settings - Fork 31
/
gulpfile.ts
117 lines (103 loc) · 3.09 KB
/
gulpfile.ts
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Copyright (c) 2017 The Absolute Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as childProcess from 'child_process';
import * as del from 'del';
import * as gulp from 'gulp';
import * as nodemon from 'gulp-nodemon';
import * as runSequence from 'run-sequence';
import tslint from 'gulp-tslint';
import * as tsc from 'gulp-typescript';
const webpack = require('webpack-stream');
gulp.task('default', (callback) => {
runSequence('webpack', 'build_server', 'run_server', 'start-mongo', callback);
});
gulp.task('lint', () => {
gulp.src('./server/**/*.ts')
.pipe(tslint({
formatter: 'codeFrame'
}))
.pipe(tslint.report({
summarizeFailureOutput: true
}));
});
gulp.task('lint:fix', () => {
gulp.src('./server/**/*.ts')
.pipe(tslint({
fix: true,
formatter: 'codeFrame'
}))
.pipe(tslint.report({
summarizeFailureOutput: true
}));
});
// FIXME(sapzape): Temporarily separated until the lint error in the client area
// is resolved. Please see https://github.com/lunchclass/absolute/issues/533
gulp.task('lint_client', () => {
gulp.src('./client/**/*.ts')
.pipe(tslint({
formatter: 'codeFrame'
}))
.pipe(tslint.report({
summarizeFailureOutput: true
}));
});
// FIXME(sapzape): Temporarily separated until the lint error in the client area
// is resolved. Please see https://github.com/lunchclass/absolute/issues/533
gulp.task('lint_client:fix', () => {
gulp.src('./client/**/*.ts')
.pipe(tslint({
fix: true,
formatter: 'codeFrame'
}))
.pipe(tslint.report({
summarizeFailureOutput: true
}));
});
gulp.task('test', ['webpack'], runCommand('jest'));
gulp.task('run_server', () => {
process.env.NODE_PATH = "out/";
nodemon({
script: 'out/server/server.js',
ignore: ['out/']
});
});
gulp.task('clean', () => {
return del('out', {force: true});
});
gulp.task('webpack', () => {
return gulp.src('./client/src/*.ts')
.pipe(webpack(require('./webpack.config.ts')))
.pipe(gulp.dest('out/client'))
});
const tsProject = tsc.createProject('tsconfig.json');
gulp.task('build_server', () => {
return tsProject.src()
.pipe(tsProject())
.js
.pipe(gulp.dest('out/server/'));
});
const mongodb_path = './third_party/mongodb';
gulp.task('start-mongo', runCommand(`${mongodb_path}/bin/mongod --dbpath ${mongodb_path}`));
gulp.task('stop-mongo', runCommand(`${mongodb_path}/bin/mongo --eval "use admin; db.shutdownServer();`));
function runCommand(command: string) {
return (cb: any) => {
childProcess.spawn(command, [], {
shell: true,
stdio : ['inherit', 'inherit', 'inherit']
});
cb();
}
}