fix Gruntfile.js to work with bew build step

v1.18.x
Julian Lam 8 years ago
parent 9bab0b53b0
commit 7a10cffb25

@ -2,8 +2,9 @@
var fork = require('child_process').fork, var fork = require('child_process').fork,
env = process.env, env = process.env,
worker, worker, updateWorker,
incomplete = []; incomplete = [],
running = 0;
module.exports = function (grunt) { module.exports = function (grunt) {
@ -19,32 +20,35 @@ module.exports = function (grunt) {
time = Date.now(); time = Date.now();
if (target === 'lessUpdated_Client') { if (target === 'lessUpdated_Client') {
fromFile = ['js', 'tpl', 'acpLess']; compiling = 'clientCSS';
compiling = 'clientLess';
} else if (target === 'lessUpdated_Admin') { } else if (target === 'lessUpdated_Admin') {
fromFile = ['js', 'tpl', 'clientLess']; compiling = 'acpCSS';
compiling = 'acpLess';
} else if (target === 'clientUpdated') { } else if (target === 'clientUpdated') {
fromFile = ['clientLess', 'acpLess', 'tpl'];
compiling = 'js'; compiling = 'js';
} else if (target === 'templatesUpdated') { } else if (target === 'templatesUpdated') {
fromFile = ['js', 'clientLess', 'acpLess'];
compiling = 'tpl'; compiling = 'tpl';
} else if (target === 'serverUpdated') { } else if (target === 'serverUpdated') {
fromFile = ['clientLess', 'acpLess', 'js', 'tpl']; // Do nothing, just restart
} }
fromFile = fromFile.filter(function (ext) { if (incomplete.indexOf(compiling) === -1) {
return incomplete.indexOf(ext) === -1; incomplete.push(compiling);
}); }
// @psychobunny, re: #5211, instead of this, just call `node app --build js` or `node app --build css,tpl` // @psychobunny, re: #5211, instead of this, just call `node app --build js` or `node app --build css,tpl`
updateArgs.push('--from-file=' + fromFile.join(',')); updateArgs.push('--build');
incomplete.push(compiling); updateArgs.push(incomplete.join(','));
worker.kill(); worker.kill();
worker = fork('app.js', updateArgs, { env: env }); if (updateWorker) {
updateWorker.kill('SIGKILL');
}
updateWorker = fork('app.js', updateArgs, { env: env });
++running;
updateWorker.on('exit', function () {
--running;
if (running === 0) {
worker = fork('app.js', args, { env: env });
worker.on('message', function () { worker.on('message', function () {
if (incomplete.length) { if (incomplete.length) {
incomplete = []; incomplete = [];
@ -55,6 +59,8 @@ module.exports = function (grunt) {
} }
}); });
} }
});
}
grunt.initConfig({ grunt.initConfig({
watch: { watch: {

@ -226,6 +226,12 @@ function start() {
// Either way, bad stuff happened. Abort start. // Either way, bad stuff happened. Abort start.
process.exit(); process.exit();
} }
if (process.send) {
process.send({
action: 'listening'
});
}
}); });
} }

Loading…
Cancel
Save