UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

47 lines (37 loc) 1.28 kB
/** * @file Get all JavaScript files in project * @description Single responsibility: Recursively find all JavaScript files in a directory */ const fs = require('fs'); const path = require('path'); /** * Get all JavaScript files in project */ async function getAllJSFiles(dirPath, excludePatterns = []) { const files = []; async function scan(currentPath) { try { const entries = await fs.promises.readdir(currentPath, { withFileTypes: true }); const promises = []; for (const entry of entries) { const fullPath = path.join(currentPath, entry.name); const relativePath = path.relative(dirPath, fullPath); // Skip excluded patterns if (excludePatterns.some(pattern => relativePath.includes(pattern))) { continue; } if (entry.isDirectory()) { promises.push(scan(fullPath)); } else if (entry.isFile() && /\.(js|jsx|ts|tsx)$/.test(entry.name)) { files.push(fullPath); } } await Promise.all(promises); } catch (error) { console.warn(`Warning: Could not scan directory ${currentPath}: ${error.message}`); } } await scan(dirPath); return files; } module.exports = getAllJSFiles;