issue-config.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.createIssueConfig = void 0;
  4. const issue_match_1 = require("./issue-match");
  5. const issue_predicate_1 = require("./issue-predicate");
  6. function createIssuePredicateFromOption(context, option) {
  7. if (Array.isArray(option)) {
  8. return (0, issue_predicate_1.composeIssuePredicates)(option.map((option) => typeof option === 'function' ? option : (0, issue_match_1.createIssuePredicateFromIssueMatch)(context, option)));
  9. }
  10. return typeof option === 'function'
  11. ? option
  12. : (0, issue_match_1.createIssuePredicateFromIssueMatch)(context, option);
  13. }
  14. function createIssueConfig(compiler, options) {
  15. const context = compiler.options.context || process.cwd();
  16. if (!options) {
  17. options = {};
  18. }
  19. const include = options.include
  20. ? createIssuePredicateFromOption(context, options.include)
  21. : (0, issue_predicate_1.createTrivialIssuePredicate)(true);
  22. const exclude = options.exclude
  23. ? createIssuePredicateFromOption(context, options.exclude)
  24. : (0, issue_predicate_1.createTrivialIssuePredicate)(false);
  25. return {
  26. predicate: (issue) => include(issue) && !exclude(issue),
  27. };
  28. }
  29. exports.createIssueConfig = createIssueConfig;