-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
106 lines (79 loc) · 2.68 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
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
// PACKAGES //
var gulp = require('gulp');
var sass = require('gulp-sass');
var nodemon = require('gulp-nodemon');
var exec = require('child_process').exec;
// MONGO //
// only kill mongo if it was used
var usedMongo = false;
// require only one ctrl+c to exit
process.once('SIGINT', function(){
if (usedMongo) {
console.log('\nshutting down mongod...');
exec('pgrep mongod | xargs kill; kill ' + process.pid);
} else {
exec('kill ' + process.pid);
}
});
// call mongod to start mongo database
var startMongo = function () {
usedMongo = true;
exec('mongod');
}
// APP SCRIPTS //
// start the database
gulp.task('startdb', function () {
startMongo();
});
// run node on the server file
gulp.task('runserver', ['startdb'], function () {
nodemon({script: 'bin/www'});
});
// UPDATING //
// install npm dependencies
gulp.task('install', function () {
exec('npm install');
});
// copy files from node_modules to lib folder
gulp.task('copylib', function () {
// angular
gulp.src('node_modules/angular/angular.min.js')
.pipe(gulp.dest('client/assets/lib'));
gulp.src('node_modules/angular/angular.min.js.map')
.pipe(gulp.dest('client/assets/lib'));
// angular-route
gulp.src('node_modules/angular-route/angular-route.min.js')
.pipe(gulp.dest('client/assets/lib'));
gulp.src('node_modules/angular-route/angular-route.min.js.map')
.pipe(gulp.dest('client/assets/lib'));
// jquery
gulp.src('node_modules/jquery/dist/jquery.min.js')
.pipe(gulp.dest('client/assets/lib'));
// semantic-ui
gulp.src('node_modules/semantic-ui-css/semantic.min.js')
.pipe(gulp.dest('client/assets/lib'));
gulp.src('node_modules/semantic-ui-css/semantic.min.css')
.pipe(gulp.dest('client/assets/lib'));
// sweetlalert
gulp.src('node_modules/sweetalert/dist/sweetalert.min.js')
.pipe(gulp.dest('client/assets/lib'));
gulp.src('node_modules/sweetalert/dist/sweetalert.css')
.pipe(gulp.dest('client/assets/lib'));
});
// run npm update and copy frontend files to lib folder
gulp.task('update', ['install', 'copylib']);
// DEV ENVIRONMENT //
// compile sass files into compressed css file
gulp.task('sass', function () {
gulp.src('client/assets/scss/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('client/assets/css'));
});
// watch for file changes while developing
gulp.task('watch', function () {
gulp.watch('client/assets/scss/**/*.scss', ['sass']);
});
// start watching for file changes and run server
gulp.task('dev', ['watch', 'runserver']);
// DEFAULT //
gulp.task('default', ['dev']);