20 lines
469 B
TypeScript
20 lines
469 B
TypeScript
function startProcess(args: string[] = []): Deno.Process {
|
|
return Deno.run({ cmd: ['deno', 'run', ...args] });
|
|
}
|
|
|
|
const throttle = 500;
|
|
let app: Deno.Process = startProcess(Deno.args);
|
|
let timeout: number|null = null;
|
|
|
|
function runApp() {
|
|
app && app.close();
|
|
app = startProcess(Deno.args);
|
|
}
|
|
|
|
for await (const event of Deno.watchFs('.')) {
|
|
if (event.kind !== "access") {
|
|
if (timeout) clearTimeout(timeout);
|
|
timeout = setTimeout(runApp, throttle);
|
|
}
|
|
}
|