|
|
|
@ -1,52 +1,5 @@
|
|
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
grunt.initConfig({
|
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
express: {
|
|
|
|
|
dev: {
|
|
|
|
|
options: {
|
|
|
|
|
script: 'app.js',
|
|
|
|
|
node_env: 'development',
|
|
|
|
|
args: ['--log-level=info'],
|
|
|
|
|
output: 'NodeBB Ready',
|
|
|
|
|
interrupt: true,
|
|
|
|
|
spawn: false,
|
|
|
|
|
interval: 100
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
serverUpdated: {
|
|
|
|
|
options: {
|
|
|
|
|
script: 'app.js',
|
|
|
|
|
node_env: 'development',
|
|
|
|
|
args: ['--from-file=less,js', '--log-level=info'],
|
|
|
|
|
output: 'NodeBB Ready',
|
|
|
|
|
interrupt: true,
|
|
|
|
|
spawn: false,
|
|
|
|
|
interval: 100
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clientUpdated: {
|
|
|
|
|
options: {
|
|
|
|
|
script: 'app.js',
|
|
|
|
|
node_env: 'development',
|
|
|
|
|
args: ['--from-file=less', '--log-level=info'],
|
|
|
|
|
output: 'NodeBB Ready',
|
|
|
|
|
interrupt: true,
|
|
|
|
|
spawn: false,
|
|
|
|
|
interval: 100
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
lessUpdated: {
|
|
|
|
|
options: {
|
|
|
|
|
script: 'app.js',
|
|
|
|
|
node_env: 'development',
|
|
|
|
|
args: ['--from-file=js', '--log-level=info'],
|
|
|
|
|
output: 'NodeBB Ready',
|
|
|
|
|
interrupt: true,
|
|
|
|
|
spawn: false,
|
|
|
|
|
interval: 100
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
less: {
|
|
|
|
|
development: {
|
|
|
|
|
files: {
|
|
|
|
@ -57,21 +10,52 @@ module.exports = function(grunt) {
|
|
|
|
|
watch: {
|
|
|
|
|
lessUpdated: {
|
|
|
|
|
files: 'public/**/*.less',
|
|
|
|
|
tasks: ['express:lessUpdated']
|
|
|
|
|
/*tasks: ['express:lessUpdated']*/
|
|
|
|
|
},
|
|
|
|
|
clientUpdated: {
|
|
|
|
|
files: 'public/src/**/*.js',
|
|
|
|
|
tasks: ['express:clientUpdated']
|
|
|
|
|
/*tasks: ['express:clientUpdated']*/
|
|
|
|
|
},
|
|
|
|
|
serverUpdated: {
|
|
|
|
|
files: ['*.js', 'src/**/*.js'],
|
|
|
|
|
tasks: ['express:serverUpdated']
|
|
|
|
|
/*tasks: ['express:serverUpdated']*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
|
grunt.loadNpmTasks('grunt-express-server');
|
|
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['express:dev', 'watch']);
|
|
|
|
|
grunt.registerTask('default', ['watch']);
|
|
|
|
|
|
|
|
|
|
var fork = require('child_process').fork,
|
|
|
|
|
env = process.env;
|
|
|
|
|
|
|
|
|
|
process.env.NODE_ENV = 'development'
|
|
|
|
|
|
|
|
|
|
var worker = fork('app.js', ['--log-level=info'], {
|
|
|
|
|
env: env,
|
|
|
|
|
silent: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grunt.event.on('watch', function(action, filepath, target) {
|
|
|
|
|
var args = [];
|
|
|
|
|
|
|
|
|
|
if (target === 'lessUpdated') {
|
|
|
|
|
args.push('--from-file=js');
|
|
|
|
|
} else if (target === 'clientUpdated') {
|
|
|
|
|
args.push('--from-file=less');
|
|
|
|
|
} else if (target === 'serverUpdated') {
|
|
|
|
|
args.push('--from-file=less,js');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args.push('--log-level=info');
|
|
|
|
|
|
|
|
|
|
worker.kill();
|
|
|
|
|
worker = fork('app.js', args, {
|
|
|
|
|
env: env,
|
|
|
|
|
silent: true
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
};
|