()
| 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 | |
| 184 | const 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); |
no test coverage detected