has-magic.js 1.0 KB

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.hasMagic = void 0;
  4. const minimatch_1 = require("minimatch");
  5. /**
  6. * Return true if the patterns provided contain any magic glob characters,
  7. * given the options provided.
  8. *
  9. * Brace expansion is not considered "magic" unless the `magicalBraces` option
  10. * is set, as brace expansion just turns one string into an array of strings.
  11. * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and
  12. * `'xby'` both do not contain any magic glob characters, and it's treated the
  13. * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`
  14. * is in the options, brace expansion _is_ treated as a pattern having magic.
  15. */
  16. const hasMagic = (pattern, options = {}) => {
  17. if (!Array.isArray(pattern)) {
  18. pattern = [pattern];
  19. }
  20. for (const p of pattern) {
  21. if (new minimatch_1.Minimatch(p, options).hasMagic())
  22. return true;
  23. }
  24. return false;
  25. };
  26. exports.hasMagic = hasMagic;
  27. //# sourceMappingURL=has-magic.js.map