Fix folder watching and push message
This commit is contained in:
parent
363fa300c2
commit
ccf38f2df4
2 changed files with 5 additions and 4 deletions
|
@ -15,13 +15,14 @@ export async function setupWatch(signaller) {
|
||||||
|
|
||||||
const watch = new CheapWatch({
|
const watch = new CheapWatch({
|
||||||
dir: config.get("scriptsFolder"),
|
dir: config.get("scriptsFolder"),
|
||||||
filter: fileFilter
|
filter: fileFilter,
|
||||||
|
watch: !config.get("dry")
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!config.get("quiet")) console.log("Watching folder", resolve(config.get("scriptsFolder")))
|
if(!config.get("quiet")) console.log("Watching folder", resolve(config.get("scriptsFolder")))
|
||||||
|
|
||||||
watch.on('+', fileEvent => signaller.emit(EventType.FileChanged, fileEvent));
|
watch.on('+', fileEvent => {if (fileEvent.stats.isFile()) signaller.emit(EventType.FileChanged, fileEvent)});
|
||||||
watch.on('-', fileEvent => signaller.emit(EventType.FileDeleted, fileEvent));
|
watch.on('-', fileEvent => {if (fileEvent.stats.isFile()) signaller.emit(EventType.FileDeleted, fileEvent)});
|
||||||
|
|
||||||
// Wait 'till filewatcher is ready to go
|
// Wait 'till filewatcher is ready to go
|
||||||
await watch.init();
|
await watch.init();
|
||||||
|
|
|
@ -10,7 +10,7 @@ export function fileChangeEventToMsg({path}){
|
||||||
"method":"pushFile",
|
"method":"pushFile",
|
||||||
"params":{
|
"params":{
|
||||||
"server":"home",
|
"server":"home",
|
||||||
"filename":path,
|
"filename":"/"+path,
|
||||||
"content":readFileSync(join(config.get("scriptsFolder"), path)).toString()
|
"content":readFileSync(join(config.get("scriptsFolder"), path)).toString()
|
||||||
},
|
},
|
||||||
"id":messageCounter++
|
"id":messageCounter++
|
||||||
|
|
Loading…
Add table
Reference in a new issue