index.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. export interface GlobOptions {
  2. /** Treat pattern as case insensitive */
  3. nocase?: boolean;
  4. /** Enable extended globbing: ?(pattern), *(pattern), +(pattern), @(pattern), !(pattern) */
  5. extglob?: boolean;
  6. }
  7. /**
  8. * Convert a glob pattern to a regular expression
  9. *
  10. * Supports:
  11. * - `/` to separate path segments
  12. * - `*` to match zero or more characters in a path segment
  13. * - `?` to match one character in a path segment
  14. * - `**` to match any number of path segments, including none
  15. * - `{}` to group conditions (e.g. `{html,txt}`)
  16. * - `[abc]`, `[a-z]`, `[!a-z]`, `[!abc]` character classes
  17. * - Extended globbing (when `extglob: true` option is set):
  18. * - `?(pattern-list)` zero or one occurrence
  19. * - `*(pattern-list)` zero or more occurrences
  20. * - `+(pattern-list)` one or more occurrences
  21. * - `@(pattern-list)` exactly one of the patterns
  22. * - `!(pattern-list)` anything except the patterns
  23. */
  24. export declare const toRegex: (pattern: string, options?: GlobOptions) => RegExp;
  25. /**
  26. * A glob pattern to match files paths against. An array or a single pattern
  27. * can be provided, if an array is given, then individual patterns will be
  28. * tested in order until one matches (OR short-circuits).
  29. *
  30. * For each pattern a string or a regular expression can be provided. If the
  31. * string starts with `/` and ends with `/<flags>?` it is treated as a regular
  32. * expression.
  33. */
  34. export type Pattern = string | RegExp | (string | RegExp)[];
  35. export type Matcher = (path: string) => boolean;
  36. export declare const toMatcher: (pattern: Pattern, options?: GlobOptions) => Matcher;