From 2c40b191ef01f42bc55e174270d1118388b49810 Mon Sep 17 00:00:00 2001 From: Rizky Date: Fri, 23 Aug 2024 11:29:03 +0700 Subject: [PATCH] fix --- app/srv/ws/sync/code/parts/init/watcher.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/srv/ws/sync/code/parts/init/watcher.ts b/app/srv/ws/sync/code/parts/init/watcher.ts index 12ac3dab..f45ade99 100644 --- a/app/srv/ws/sync/code/parts/init/watcher.ts +++ b/app/srv/ws/sync/code/parts/init/watcher.ts @@ -1,12 +1,13 @@ import { FSWatcher, statSync, watch } from "fs"; import { readdir } from "node:fs/promises"; import { join } from "path"; +import { code } from "../../code"; const path = process.argv.splice(2).join(" "); const watchers = {} as Record; -const createWatcher = (p: string, recursive: boolean) => { +const createWatcher = (p: string, recursive: boolean, prefix?: string) => { return watch(p, { recursive }, (e, filename) => { if (filename === "global.d.ts") return; if ( @@ -15,7 +16,7 @@ const createWatcher = (p: string, recursive: boolean) => { filename?.endsWith(".css") || filename?.endsWith(".html") ) { - process.send?.([e, filename]); + process.send?.([e, (prefix || "") + filename]); } }); }; @@ -27,7 +28,7 @@ for (const file of files) { const fullpath = join(path, file); const stats = statSync(fullpath); if (stats.isDirectory()) { - watchers[file] = createWatcher(fullpath, true); + watchers[file] = createWatcher(fullpath, true, `${file}/`); } } setInterval(() => {}, 1e9);