From db91aa5fda86ab66542d0941ef69935e8ed718d4 Mon Sep 17 00:00:00 2001 From: Ethan Davidson <31261035+EthanThatOneKid@users.noreply.github.com> Date: Sat, 18 Dec 2021 11:58:39 -0800 Subject: [PATCH] Create watch_serve.ts --- fart_server/watch_serve.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 fart_server/watch_serve.ts diff --git a/fart_server/watch_serve.ts b/fart_server/watch_serve.ts new file mode 100644 index 0000000..c1faeab --- /dev/null +++ b/fart_server/watch_serve.ts @@ -0,0 +1,16 @@ +const makeWorker = () => { + const workerPath = new URL("./serve.ts", import.meta.url).href; + return new Worker(workerPath, { type: "module", deno: true }) +}; + +const resetWorker = () => { + worker.terminate(); + worker = makeWorker(); +} + +let worker = makeWorker(); + +for await (const event of Deno.watchFs(".")) { + console.log(">>>> event", event); + resetWorker(); +} \ No newline at end of file