监控文件夹下文件变化
把要监控的文件名写到test.txt里
var fs = require('fs');
var stream = fs.createReadStream('test.txt');
var files = fs.readdirSync(process.cwd());
files.forEach(function (file) {
if(/\.json/.test(file)){
fs.watchFile(process.cwd() +'/'+file,function(){
console.log('-'+file+'changed!');
});
}
});
网友评论