-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
41 lines (36 loc) · 1.26 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
var gulp = require('gulp');
var exec = require('child_process').exec;
var color = require('color');
var nodemon = require('gulp-nodemon');
gulp.task('default', function () {
// 将你的默认的任务代码放在这
});
// 一键启动
gulp
.task('server', function () {
new Promise(function (resolve, reject) {
exec('mongo admin --eval "db.shutdownServer()"', function (err, stdout, stderr) {
exec('mongod --dbpath=./db --port 27017', function (err, stdout, stderr) {
if (err) {
reject(err)
} else {
resolve()
}
});
resolve();
});
}).then(function () {
console.log('启动数据库服务');
nodemon({
script: 'app.js',
ext: 'js coffee jade es',
ignore: 'gulpfile.babel.js',
env: {'NODE_ENV': 'development'},
stdout: true
}).on('restart', function () {
connect.reload()
})
}, function () {
console.log('启动数据库服务错误, error: ' + err);
});
});