All files / lib/analyzers utils.js

100% Statements 14/14
87.5% Branches 7/8
100% Functions 1/1
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30        31x 31x   31x 31x     31x 1x     30x 5x 5x 25x   25x 25x 6x         31x    
import fs from 'fs-extra';
import path from 'path';
 
export async function recursiveGlob(dir, pattern) {
  const results = [];
  const entries = await fs.readdir(dir, { withFileTypes: true });
 
  for (const entry of entries) {
    const fullPath = path.join(dir, entry.name);
 
    // Skip common ignores
    if (['node_modules', '.git', 'dist', 'build', 'coverage', '.venv', 'venv'].includes(entry.name)) {
      continue;
    }
 
    if (entry.isDirectory()) {
      const subResults = await recursiveGlob(fullPath, pattern);
      results.push(...subResults);
    } else Eif (entry.isFile()) {
      // Simple pattern: '**/*.tf' → match file extension
      const ext = pattern.split('.').pop();
      if (entry.name.endsWith(`.${ext}`)) {
        results.push(fullPath);
      }
    }
  }
 
  return results;
}