only monitor transpileable files
This commit is contained in:
parent
85bfaf5386
commit
2d688e71e6
33
server.tsx
33
server.tsx
@ -256,25 +256,36 @@ const SocketsBroadcast =(inData:string)=>{ for (const socket of Sockets){ socket
|
|||||||
const FilesChanged:Map<string, string> = new Map();
|
const FilesChanged:Map<string, string> = new Map();
|
||||||
const ProcessFiles =debounce(async()=>
|
const ProcessFiles =debounce(async()=>
|
||||||
{
|
{
|
||||||
console.log("Files changed...")
|
console.log("Processing Files...", FilesChanged);
|
||||||
for await (const [file, action] of FilesChanged)
|
for await (const [path, action] of FilesChanged)
|
||||||
{
|
{
|
||||||
const pathname = file.substring(Deno.cwd().length).replaceAll("\\", "/");
|
const key = path.substring(Deno.cwd().length).replaceAll("\\", "/");
|
||||||
console.log(pathname, action);
|
console.log(key, action);
|
||||||
if(Transpileable(pathname))
|
|
||||||
|
if(action != "remove")
|
||||||
{
|
{
|
||||||
if(action !== "remove")
|
await TranspileFS(path, key, false);
|
||||||
{
|
console.log(` ...cached "${key}"`);
|
||||||
await TranspileFS(file, pathname, false);
|
SocketsBroadcast(key);
|
||||||
console.log(` ...cached "${pathname}"`);
|
|
||||||
SocketsBroadcast(pathname);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Transpiled.delete(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FilesChanged.clear();
|
FilesChanged.clear();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
for await (const event of Deno.watchFs(Deno.cwd()))
|
for await (const event of Deno.watchFs(Deno.cwd()))
|
||||||
{
|
{
|
||||||
event.paths.forEach( path => FilesChanged.set(path, event.kind) );
|
event.paths.forEach( path =>
|
||||||
|
{
|
||||||
|
if(Transpileable(path))
|
||||||
|
{
|
||||||
|
FilesChanged.set(path, event.kind);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(FilesChanged.size)
|
||||||
|
{
|
||||||
ProcessFiles();
|
ProcessFiles();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user