Works, easy :D
This commit is contained in:
23
mod.ts
Normal file
23
mod.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
function startProcess(args: string[] = []): Deno.Process {
|
||||
return Deno.run({ cmd: ['deno', ...args] });
|
||||
}
|
||||
|
||||
const throttle = 500;
|
||||
let app: Deno.Process = startProcess(Deno.args);
|
||||
let appInitTime: number = Date.now();
|
||||
let timeout: number|null = null;
|
||||
|
||||
function runApp() {
|
||||
appInitTime = Date.now();
|
||||
app && app.close();
|
||||
app = startProcess(Deno.args);
|
||||
}
|
||||
|
||||
runApp();
|
||||
|
||||
for await (const event of Deno.fsEvents('.')) {
|
||||
if (event.kind !== "access") {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
timeout = setTimeout(runApp, throttle);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user