clovie 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -209,19 +209,34 @@ async function main() {
209
209
 
210
210
  // Set up file watching
211
211
  console.log('👀 Setting up file watching...');
212
- const watchPaths = [
213
- config.views,
214
- config.partials,
215
- config.styles,
216
- config.scripts,
217
- ].filter(Boolean); // Remove undefined paths
218
212
 
219
- const watchers = clovie.file.watch(watchPaths);
213
+ // Debug: Check if config service is available
214
+ console.log(' Debug: config service available:', !!clovie.config);
215
+ console.log(' Debug: getWatchPaths available:', !!clovie.config?.getWatchPaths);
220
216
 
221
- // Set up event handlers for each watcher
222
- watchers.forEach(watcher => {
223
- watcher.on('change', async (filePath) => {
224
- console.log(`🔄 File changed: ${filePath}`);
217
+ // Use discovered config paths from Config service
218
+ let watchPaths;
219
+ try {
220
+ watchPaths = clovie.config.getWatchPaths();
221
+ } catch (error) {
222
+ console.error(' Error getting watch paths:', error.message);
223
+ // Fallback to manual discovery for debugging
224
+ const discoveredConfig = clovie.config.get();
225
+ watchPaths = [
226
+ discoveredConfig?.views,
227
+ discoveredConfig?.partials,
228
+ discoveredConfig?.styles,
229
+ discoveredConfig?.scripts,
230
+ discoveredConfig?.assets
231
+ ].filter(Boolean);
232
+ console.log(' Using fallback watch paths:', watchPaths);
233
+ }
234
+
235
+ console.log(` Watching ${watchPaths.length} directories:`, watchPaths);
236
+
237
+ // Set up file watchers with change handler
238
+ const watchers = clovie.file.watch(watchPaths, {}, {
239
+ onChange: async (filePath) => {
225
240
  console.log('🔄 Triggering rebuild...');
226
241
 
227
242
  try {
@@ -235,11 +250,7 @@ async function main() {
235
250
  } catch (error) {
236
251
  console.error('❌ Rebuild failed:', error.message);
237
252
  }
238
- });
239
-
240
- watcher.on('error', (error) => {
241
- console.error('❌ File watcher error:', error);
242
- });
253
+ }
243
254
  });
244
255
 
245
256
  console.log(`🌐 Development server running at http://localhost:${config.port || 3000}`);