|
|
@ -1,23 +1,23 @@
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var fork = require('child_process').fork,
|
|
|
|
var fork = require('child_process').fork;
|
|
|
|
env = process.env,
|
|
|
|
var env = process.env;
|
|
|
|
worker, updateWorker,
|
|
|
|
var worker, updateWorker, initWorker;
|
|
|
|
incomplete = [],
|
|
|
|
var incomplete = [];
|
|
|
|
running = 0;
|
|
|
|
var running = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function (grunt) {
|
|
|
|
module.exports = function (grunt) {
|
|
|
|
var args = [];
|
|
|
|
var args = [];
|
|
|
|
|
|
|
|
var initArgs = ['--build'];
|
|
|
|
if (!grunt.option('verbose')) {
|
|
|
|
if (!grunt.option('verbose')) {
|
|
|
|
args.push('--log-level=info');
|
|
|
|
args.push('--log-level=info');
|
|
|
|
|
|
|
|
initArgs.push('--log-level=info');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function update(action, filepath, target) {
|
|
|
|
function update(action, filepath, target) {
|
|
|
|
var updateArgs = args.slice(),
|
|
|
|
var updateArgs = args.slice();
|
|
|
|
fromFile = '',
|
|
|
|
var compiling = '';
|
|
|
|
compiling = '',
|
|
|
|
var time = Date.now();
|
|
|
|
time = Date.now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (target === 'lessUpdated_Client') {
|
|
|
|
if (target === 'lessUpdated_Client') {
|
|
|
|
compiling = 'clientCSS';
|
|
|
|
compiling = 'clientCSS';
|
|
|
@ -44,12 +44,16 @@ module.exports = function (grunt) {
|
|
|
|
if (updateWorker) {
|
|
|
|
if (updateWorker) {
|
|
|
|
updateWorker.kill('SIGKILL');
|
|
|
|
updateWorker.kill('SIGKILL');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateWorker = fork('app.js', updateArgs, { env: env });
|
|
|
|
updateWorker = fork('app.js', updateArgs, {
|
|
|
|
|
|
|
|
env: env
|
|
|
|
|
|
|
|
});
|
|
|
|
++running;
|
|
|
|
++running;
|
|
|
|
updateWorker.on('exit', function () {
|
|
|
|
updateWorker.on('exit', function () {
|
|
|
|
--running;
|
|
|
|
--running;
|
|
|
|
if (running === 0) {
|
|
|
|
if (running === 0) {
|
|
|
|
worker = fork('app.js', args, { env: env });
|
|
|
|
worker = fork('app.js', args, {
|
|
|
|
|
|
|
|
env: env
|
|
|
|
|
|
|
|
});
|
|
|
|
worker.on('message', function () {
|
|
|
|
worker.on('message', function () {
|
|
|
|
if (incomplete.length) {
|
|
|
|
if (incomplete.length) {
|
|
|
|
incomplete = [];
|
|
|
|
incomplete = [];
|
|
|
@ -137,9 +141,17 @@ module.exports = function (grunt) {
|
|
|
|
grunt.registerTask('default', ['watch']);
|
|
|
|
grunt.registerTask('default', ['watch']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env.NODE_ENV = 'development';
|
|
|
|
env.NODE_ENV = 'development';
|
|
|
|
|
|
|
|
|
|
|
|
worker = fork('app.js', args, { env: env });
|
|
|
|
initWorker = fork('app.js', initArgs, {
|
|
|
|
|
|
|
|
env: env
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initWorker.on('exit', function () {
|
|
|
|
|
|
|
|
worker = fork('app.js', args, {
|
|
|
|
|
|
|
|
env: env
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
grunt.event.on('watch', update);
|
|
|
|
grunt.event.on('watch', update);
|
|
|
|
};
|
|
|
|
};
|