-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
43 lines (35 loc) · 1.19 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const {exec, spawn} = require('child_process');
var phpServ;
var composeUp;
function dev(callback){
gulp.watch(['dist/scss/*.scss'], {ignoreInitial: false}, buildSass);
let processCount = 0;
composeUp = spawn('docker-compose', ['up'], {detached: true, stdio: ['ignore', 'inherit', 'inherit']});
processCount++;
composeUp.on('exit', () => processCount = exitIfClean(processCount, callback));
phpServ = spawn('php', ['-S', 'localhost:8080', '-t', 'app/public'], {detached: true, stdio: ['ignore', 'inherit', 'inherit']});
processCount++;
phpServ.on('exit', () => processCount = exitIfClean(processCount, callback));
}
function buildSass() {
return gulp.src(['dist/scss/*.scss','node_modules/bootstrap/scss/bootstrap.scss'])
.pipe(sass())
.pipe(gulp.dest('app/public/css'));
}
function exitIfClean(processCount, callback){
processCount--;
if(processCount == 0){
callback();
process.exit();
}
return processCount;
}
process.on('SIGINT', () => {
console.log('\nReceived SIGINT, cleaning up...');
composeUp.kill('SIGINT');
phpServ.kill('SIGINT');
});
exports.default = dev;
exports.sass = buildSass;