-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
39 lines (32 loc) · 960 Bytes
/
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
const { spawn } = require('child_process');
const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
const gutil = require('gulp-util');
const path = require('path');
const fs = require('fs');
const { config } = require('./config');
const consoleLog = data => gutil.log(data.toString().trim());
const toWatch = ['./src', './swagger'];
if (fs.existsSync(config.swaggerDirPath)) {
toWatch.push(config.swaggerDirPath)
}
gulp.task('server', () => nodemon({
script: './bin/www',
watch: toWatch,
ext: 'js yaml',
ignore: ['build/**'],
env: {
DEBUG: 'server:server',
NODE_PATH: path.resolve(__dirname, 'server'),
NODE_ENV: 'development',
},
}));
gulp.task('mongo', (callback) => {
const dbProcess = spawn('mongod');
dbProcess.stderr.on('data', consoleLog);
dbProcess.on('close', (code) => {
consoleLog(`Database was stopped with code ${code}`);
callback();
});
});
gulp.task('run:dev', ['mongo', 'server']);