Files
NodeBB/Gruntfile.js

75 lines
1.9 KiB
JavaScript
Raw Normal View History

"use strict";
var fork = require('child_process').fork,
env = process.env,
worker;
process.env.NODE_ENV = 'development';
2015-01-30 13:06:04 -05:00
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
files: {
'public/bin/manifest.css': 'source/manifest.less'
2015-01-30 13:06:04 -05:00
}
}
},
watch: {
lessUpdated: {
files: ['public/**/*.less', 'node_modules/nodebb-*/*.less', 'node_modules/nodebb-*/*/*.less', 'node_modules/nodebb-*/*/*/*.less', 'node_modules/nodebb-*/*/*/*/*.less']
},
clientUpdated: {
files: ['public/src/**/*.js', 'node_modules/nodebb-*/*.js', 'node_modules/nodebb-*/*/*.js', 'node_modules/nodebb-*/*/*/*.js', 'node_modules/nodebb-*/*/*/*/*.js']
},
serverUpdated: {
2015-02-24 15:46:37 -05:00
files: ['*.js', 'src/**/*.js']
},
templatesUpdated: {
files: ['src/views/**/*.tpl', 'node_modules/nodebb-*/*.tpl', 'node_modules/nodebb-*/*/*.tpl', 'node_modules/nodebb-*/*/*/*.tpl', 'node_modules/nodebb-*/*/*/*/*.tpl']
2015-01-30 13:06:04 -05:00
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
2015-02-24 15:34:05 -05:00
grunt.registerTask('default', ['watch']);
worker = fork('app.js', [], { env: env });
var incomplete = [];
2015-02-24 15:34:05 -05:00
grunt.event.on('watch', function(action, filepath, target) {
var args = ['--log-level=info'],
fromFile = '',
compiling = '';
2015-02-24 15:34:05 -05:00
if (target === 'lessUpdated') {
fromFile = ['js','tpl'];
compiling = 'less';
2015-02-24 15:34:05 -05:00
} else if (target === 'clientUpdated') {
fromFile = ['less','tpl'];
compiling = 'js';
2015-02-24 15:46:37 -05:00
} else if (target === 'templatesUpdated') {
fromFile = ['js','less'];
compiling = 'tpl';
2015-02-24 15:34:05 -05:00
} else if (target === 'serverUpdated') {
fromFile = ['less','js','tpl'];
2015-02-24 15:34:05 -05:00
}
fromFile = fromFile.filter(function(ext) {
return incomplete.indexOf(ext) === -1;
});
args.push('--from-file=' + fromFile.join(','));
incomplete.push(compiling);
2015-02-24 15:34:05 -05:00
worker.kill();
worker = fork('app.js', args, { env: env });
worker.on('message', function() {
incomplete = [];
2015-02-24 15:34:05 -05:00
});
});
2015-01-30 13:06:04 -05:00
};