@every-env/cli
Version:
Multi-agent orchestrator for AI-powered development workflows
30 lines • 1.07 kB
JavaScript
import { glob } from 'glob';
import { minimatch } from 'minimatch';
import { basename, join } from 'path';
export class FilePatternMatcher {
async match(pattern, basePath = process.cwd()) {
const allFiles = new Set();
// Collect all matching files
for (const filePattern of pattern.files) {
const matches = await glob(filePattern, {
cwd: basePath,
ignore: pattern.exclude || [],
nodir: true,
});
matches.forEach(file => allFiles.add(file));
}
// Apply exclude patterns
const files = Array.from(allFiles).filter(file => {
if (!pattern.exclude)
return true;
return !pattern.exclude.some(excludePattern => minimatch(file, excludePattern));
});
// Convert to FileMatch objects
return files.map(file => ({
path: join(basePath, file),
relativePath: file,
name: basename(file),
}));
}
}
//# sourceMappingURL=file-pattern.js.map