1 | const chokidar=require('chokidar');
|
2 | const path=require('path');
|
3 | const logger=require('./logger');
|
4 | const build={};
|
5 |
|
6 | build.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 | }
|
24 | module.exports=build; |
\ | No newline at end of file |