UNPKG

840 BJavaScriptView Raw
1const chokidar=require('chokidar');
2const path=require('path');
3const logger=require('./logger');
4const build={};
5
6build.watch=function(callback){
7 let watcher=chokidar.watch(path.join(__dirname,'../../../'),{persistent:true,usePolling:true})
8 watcher.on('ready',function(){
9 logger.info("build","Initial scan complete. Ready for changes.");
10 });
11 watcher.on('add',function(dir){
12 logger.info("build",[dir,"has been created"].join(''));
13 callback("created",dir);
14 });
15 watcher.on('change',function(dir){
16 logger.info("build",[dir,"has been modified"].join(''));
17 callback("modified",dir);
18 });
19 watcher.on('unlink',function(dir){
20 logger.info("build",[dir,"has been removed"].join(''));
21 callback("removed",dir);
22 });
23}
24module.exports=build;
\No newline at end of file