connect-compiler 满足不了我的需求, 编译过程是Makefile写的, 希望当某个文件夹被改变后, 自动执行某个命令. 是否有这样的工具?
感谢 [[[[[[[@jiyinyiyong](/user/jiyinyiyong)](/user/jiyinyiyong)](/user/jiyinyiyong)](/user/jiyinyiyong)](/user/jiyinyiyong)](/user/jiyinyiyong)](/user/jiyinyiyong)
var watch = require('watch')
, spawn = require('child_process').spawn
;
watch.createMonitor('.', { ignoreDotFiles: true }, function (monitor) {
monitor.on("created", function (f, stat) {
// Handle file changes
})
monitor.on("changed", function (f, curr, prev) {
if(f == 'Makefile' || /\.jade$/.test(f)) make();
})
monitor.on("removed", function (f, stat) {
// Handle removed files
})
});
function make() {
console.log('start make')
var makeprg = spawn('make')
makeprg.stdout.on('data', function(data) {
console.log(data.toString());
});
makeprg.stderr.on('data', function(data) {
console.log(data.toString());
});
makeprg.on('exit', function(code) {
console.log('make done ' + code);
})
}