-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
61 lines (56 loc) · 1.97 KB
/
gulpfile.js
File metadata and controls
61 lines (56 loc) · 1.97 KB
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
var gulp = require('gulp'),
livereload = require('gulp-livereload'); // Requiring gulp-livereload task.
function errorLog(error) {
console.error(error);
this.emit('end');
}
/* -- JSHINT ---- */
var jshint = require('gulp-jshint');
gulp.task('jshint', function() {
return gulp.src('./app/*/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
/* -- JSCS ---- */
var file = 'models/data.js';
var jscs = require('gulp-jscs');
gulp.task('jscs', function () {
return gulp.src('./app/' + file)
.pipe(jscs({
//fix: true,
preset : 'node-style-guide'
}))
.pipe(gulp.dest('./app/models'));;
});
// --------------------------------------------------
// Build resources - JS and CSS
var shell = require('gulp-shell');
gulp.task('build', function(){
var stream = gulp.src('public/')
.pipe(shell([
'node build/r.js -o build/build.js optimize=none'
]))
.pipe(livereload());
return stream;
});
//Run server after running the build - to make it serial
gulp.task('server', ['build'], shell.task([
'killall node &',//kill other previous node process
"sudo lsof -i TCP:27017 | grep LISTEN | awk '{print $2}' | sudo xargs kill -9",//Kill mongodb
'sudo mongod --dbpath ./logs/mongo/db --fork --logpath ./logs/mongo/mongod.log',//start mongodb
'forever -o out.log -e err.log --watchDirectory app --watch -c "node -r dotenv/config --debug" server.js'
]))
// gulp.task('server', ['build'], shell.task([
// 'node server.js'
// ]))
// Watch Task
// Watches JS
gulp.task('watch', function () {
livereload.listen(); // Calling lister on livereload task, which will start listening for livereload client.
gulp.watch(['public/res/**/*', '!public/res/uploads'], ['build']);
// gulp.watch('public/res/js/**/*.js', ['build']);
//gulp.watch('public/res/css/**/*.css', ['build']);
//gulp.watch('public/res/js/**/*.html', ['build']);
});
// gulp.task('default', ['uploadJS', 'uploadCSS']);
gulp.task('default', ['watch', 'server']);