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