/
githubmirror
/
tldraw
Обзор
Документация
Войти
/
githubmirror
/
tldraw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
apps/docs/watcher.ts
38 строк
1 KB
Mime Čuvalo
chore: sort imports using oxfmt (#8330)
24 мар 2026, 15:22
Не верифицирован
24 мар 2026, 15:22
374dfed
Код
Авторство
О чём код?
import fs from 'fs' import { WebSocketServer } from 'ws' import { refreshContent } from './scripts/lib/refreshContent' import { debounce } from './utils/debounce' import { nicelog } from './utils/nicelog' // set environment variable to development // @ts-expect-error whatever process.env.NODE_ENV = 'development' refreshContent({ silent: true }) fs.watch( 'content', { persistent: true, recursive: true }, debounce(async (eventType, fileName) => { nicelog(`Refreshing after ${eventType}: ${fileName}`) // todo: if a file was only updated, then only update the file that changed, any links that point to it, etc. try { await refreshContent({ silent: true }) clients.forEach((ws) => ws.send('refresh')) } catch (e: any) { nicelog(`x Could not refresh content: ${e.message}`) } }, 250) ) const wss = new WebSocketServer({ port: 3201 }) const clients = new Set<any>() wss.on('connection', function connection(ws) { clients.add(ws) ws.on('error', console.error) ws.on('close', () => { clients.delete(ws) }) })