groove-dev 0.12.7 → 0.12.8

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.
@@ -392,19 +392,33 @@ export function createApi(app, daemon) {
392
392
  .sort((a, b) => a.name.localeCompare(b.name))
393
393
  .map((e) => {
394
394
  const childPath = relPath ? `${relPath}/${e.name}` : e.name;
395
- // Check if this dir has subdirectories (for expand arrow)
395
+ const childFull = resolve(fullPath, e.name);
396
396
  let hasChildren = false;
397
+ let childCount = 0;
398
+ let fileCount = 0;
397
399
  try {
398
- hasChildren = readdirSync(resolve(fullPath, e.name), { withFileTypes: true })
399
- .some((c) => c.isDirectory() && !c.name.startsWith('.') && c.name !== 'node_modules');
400
+ const children = readdirSync(childFull, { withFileTypes: true });
401
+ for (const c of children) {
402
+ if (c.name.startsWith('.') || c.name === 'node_modules') continue;
403
+ if (c.isDirectory()) { childCount++; hasChildren = true; }
404
+ else fileCount++;
405
+ }
400
406
  } catch { /* unreadable */ }
401
- return { name: e.name, path: childPath, hasChildren };
407
+ return { name: e.name, path: childPath, hasChildren, childCount, fileCount };
402
408
  });
403
409
 
410
+ // Count files in current dir
411
+ let currentFiles = 0;
412
+ try {
413
+ currentFiles = readdirSync(fullPath, { withFileTypes: true })
414
+ .filter((e) => e.isFile() && !e.name.startsWith('.')).length;
415
+ } catch { /* ignore */ }
416
+
404
417
  res.json({
405
418
  current: relPath || '.',
406
419
  parent: relPath ? relPath.split('/').slice(0, -1).join('/') : null,
407
420
  dirs: entries,
421
+ fileCount: currentFiles,
408
422
  });
409
423
  } catch (err) {
410
424
  res.status(500).json({ error: err.message });