MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / watch

Function watch

apps/api/src/templates/email/build.ts:173–205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171 if (templates.length === 0) {
172 console.log("No .hbs template files found.");
173
174 return;
175 }
176
177 for (const template of templates) {
178 buildTemplate(template);
179 }
180
181 console.log(`\n✓ Built ${String(templates.length)} template(s)`);
182};
183
184const watch = async (): Promise<void> => {
185 /*
186 * Dynamic import keeps chokidar out of the prod install path: the one-shot
187 * `build:templates` script only needs handlebars + fs, and prod images
188 * run `bun install --production` (devDeps excluded).
189 */
190 const { default: chokidar } = await import("chokidar");
191
192 console.log("Watching for changes...\n");
193 registerPartials();
194
195 const watcher = chokidar.watch([
196 path.join(TEMPLATES_DIR, "**/*.hbs"),
197 path.join(COMPONENTS_DIR, "**/*.hbs"),
198 ]);
199
200 watcher.on("change", (filePath: string) => {
201 console.log(`\nChange detected: ${filePath}`);
202
203 if (filePath.includes("components")) {
204 registerHelpers();
205 registerPartials();
206 buildAll();
207 } else {
208 buildTemplate(filePath);

Callers 1

build.tsFile · 0.85

Calls 4

buildAllFunction · 0.85
buildTemplateFunction · 0.85
registerPartialsFunction · 0.70
registerHelpersFunction · 0.70

Tested by

no test coverage detected