Grunt.js永远守望 [英] Grunt.js Watch Forever
问题描述
目标:
我试图在 Gruntfile中运行
作为守护进程。 watch
任务.js
通常情况下,我会执行如下脚本: grunt watch
。
Gruntfile.js:
module.exports =函数(grunt){
grunt.initConfig({
concat:{
options:{
separator:''
},
dist:{
src:['static / js / ** / *。js'],
dest:'app.js'
}
},
观看:{
files:['<%= concat.dist.src%>'],
tasks:['concat']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
};
问题:
作为一个守护进程产生 grunt watch
? 更新:
看起来好像已经做了一些考虑:
https://github.com/shama/grunt-hub#watching-forever
https://github.com/shama/grunt-hub/issues/3 p>
您可以使用 https ://github.com/nodejitsu/forever exmaple
forever start gruntstart.js
code>
gruntstart.js:
var exec = require('child_process')。exec;
$ b $ exec('grunt watch> log / grunt.log',
function(error,stdout,stderr){
console.log('stdout:'+ stdout) ;
console.log('stderr:'+ stderr);
if(error!== null){
console.log('exec error:'+ error);
}
});
Goal:
I am trying to run a watch
task in my Gruntfile.js
as a daemon.
Normally, I would execute this script like: grunt watch
.
Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
concat: {
options: {
separator: ''
},
dist: {
src: ['static/js/**/*.js'],
dest: 'app.js'
}
},
watch: {
files: ['<%= concat.dist.src %>'],
tasks: ['concat']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
};
Question:
How do I spawn grunt watch
as a daemon?
Update:
It appears as though considerations for this have already been made:
https://github.com/shama/grunt-hub#watching-forever
https://github.com/shama/grunt-hub/issues/3
you can use https://github.com/nodejitsu/forever exmaple
forever start gruntstart.js
gruntstart.js:
var exec = require('child_process').exec;
exec('grunt watch > log/grunt.log',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
这篇关于Grunt.js永远守望的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!