@diullei/codeguardian
Version:
Open-source developer tool to validate and enforce architectural rules, especially for AI-generated code
37 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectFilesRule = void 0;
const minimatch_1 = require("minimatch");
const core_1 = require("../core");
class SelectFilesRule extends core_1.SelectorRule {
pathPattern;
status;
excludePattern;
selectAll;
constructor(id, pathPattern, status, excludePattern, selectAll = false) {
super(id);
this.pathPattern = pathPattern;
this.status = status;
this.excludePattern = excludePattern;
this.selectAll = selectAll;
}
async select(context) {
const allFiles = this.selectAll
? await context.repository.getAllFiles()
: await context.repository.getFiles(context.diff, context.mode);
return allFiles.filter(file => {
if (this.pathPattern && !(0, minimatch_1.minimatch)(file.path, this.pathPattern)) {
return false;
}
if (!this.selectAll && this.status && !this.status.includes(file.status)) {
return false;
}
if (this.excludePattern && (0, minimatch_1.minimatch)(file.path, this.excludePattern)) {
return false;
}
return true;
});
}
}
exports.SelectFilesRule = SelectFilesRule;
//# sourceMappingURL=SelectFilesRule.js.map