index.d.ts 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import { AST } from './ast.js';
  2. export type Platform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd';
  3. export interface MinimatchOptions {
  4. /** do not expand `{x,y}` style braces */
  5. nobrace?: boolean;
  6. /** do not treat patterns starting with `#` as a comment */
  7. nocomment?: boolean;
  8. /** do not treat patterns starting with `!` as a negation */
  9. nonegate?: boolean;
  10. /** print LOTS of debugging output */
  11. debug?: boolean;
  12. /** treat `**` the same as `*` */
  13. noglobstar?: boolean;
  14. /** do not expand extglobs like `+(a|b)` */
  15. noext?: boolean;
  16. /** return the pattern if nothing matches */
  17. nonull?: boolean;
  18. /** treat `\\` as a path separator, not an escape character */
  19. windowsPathsNoEscape?: boolean;
  20. /**
  21. * inverse of {@link MinimatchOptions.windowsPathsNoEscape}
  22. * @deprecated
  23. */
  24. allowWindowsEscape?: boolean;
  25. /**
  26. * Compare a partial path to a pattern. As long as the parts
  27. * of the path that are present are not contradicted by the
  28. * pattern, it will be treated as a match. This is useful in
  29. * applications where you're walking through a folder structure,
  30. * and don't yet have the full path, but want to ensure that you
  31. * do not walk down paths that can never be a match.
  32. */
  33. partial?: boolean;
  34. /** allow matches that start with `.` even if the pattern does not */
  35. dot?: boolean;
  36. /** ignore case */
  37. nocase?: boolean;
  38. /** ignore case only in wildcard patterns */
  39. nocaseMagicOnly?: boolean;
  40. /** consider braces to be "magic" for the purpose of `hasMagic` */
  41. magicalBraces?: boolean;
  42. /**
  43. * If set, then patterns without slashes will be matched
  44. * against the basename of the path if it contains slashes.
  45. * For example, `a?b` would match the path `/xyz/123/acb`, but
  46. * not `/xyz/acb/123`.
  47. */
  48. matchBase?: boolean;
  49. /** invert the results of negated matches */
  50. flipNegate?: boolean;
  51. /** do not collapse multiple `/` into a single `/` */
  52. preserveMultipleSlashes?: boolean;
  53. /**
  54. * A number indicating the level of optimization that should be done
  55. * to the pattern prior to parsing and using it for matches.
  56. */
  57. optimizationLevel?: number;
  58. /** operating system platform */
  59. platform?: Platform;
  60. /**
  61. * When a pattern starts with a UNC path or drive letter, and in
  62. * `nocase:true` mode, do not convert the root portions of the
  63. * pattern into a case-insensitive regular expression, and instead
  64. * leave them as strings.
  65. *
  66. * This is the default when the platform is `win32` and
  67. * `nocase:true` is set.
  68. */
  69. windowsNoMagicRoot?: boolean;
  70. /**
  71. * max number of `{...}` patterns to expand. Default 100_000.
  72. */
  73. braceExpandMax?: number;
  74. /**
  75. * Max number of non-adjacent `**` patterns to recursively walk down.
  76. *
  77. * The default of 200 is almost certainly high enough for most purposes,
  78. * and can handle absurdly excessive patterns.
  79. */
  80. maxGlobstarRecursion?: number;
  81. /**
  82. * Max depth to traverse for nested extglobs like `*(a|b|c)`
  83. *
  84. * Default is 2, which is quite low, but any higher value
  85. * swiftly results in punishing performance impacts. Note
  86. * that this is *not* relevant when the globstar types can
  87. * be safely coalesced into a single set.
  88. *
  89. * For example, `*(a|@(b|c)|d)` would be flattened into
  90. * `*(a|b|c|d)`. Thus, many common extglobs will retain good
  91. * performance and never hit this limit, even if they are
  92. * excessively deep and complicated.
  93. *
  94. * If the limit is hit, then the extglob characters are simply
  95. * not parsed, and the pattern effectively switches into
  96. * `noextglob: true` mode for the contents of that nested
  97. * sub-pattern. This will typically _not_ result in a match,
  98. * but is considered a valid trade-off for security and
  99. * performance.
  100. */
  101. maxExtglobRecursion?: number;
  102. }
  103. export declare const minimatch: {
  104. (p: string, pattern: string, options?: MinimatchOptions): boolean;
  105. sep: Sep;
  106. GLOBSTAR: typeof GLOBSTAR;
  107. filter: (pattern: string, options?: MinimatchOptions) => (p: string) => boolean;
  108. defaults: (def: MinimatchOptions) => typeof minimatch;
  109. braceExpand: (pattern: string, options?: MinimatchOptions) => string[];
  110. makeRe: (pattern: string, options?: MinimatchOptions) => false | MMRegExp;
  111. match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];
  112. AST: typeof AST;
  113. Minimatch: typeof Minimatch;
  114. escape: (s: string, { windowsPathsNoEscape, magicalBraces, }?: Pick<MinimatchOptions, "windowsPathsNoEscape" | "magicalBraces">) => string;
  115. unescape: (s: string, { windowsPathsNoEscape, magicalBraces, }?: Pick<MinimatchOptions, "windowsPathsNoEscape" | "magicalBraces">) => string;
  116. };
  117. export type Sep = '\\' | '/';
  118. export declare const sep: Sep;
  119. export declare const GLOBSTAR: unique symbol;
  120. export declare const filter: (pattern: string, options?: MinimatchOptions) => (p: string) => boolean;
  121. export declare const defaults: (def: MinimatchOptions) => typeof minimatch;
  122. export declare const braceExpand: (pattern: string, options?: MinimatchOptions) => string[];
  123. export declare const makeRe: (pattern: string, options?: MinimatchOptions) => false | MMRegExp;
  124. export declare const match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];
  125. export type MMRegExp = RegExp & {
  126. _src?: string;
  127. _glob?: string;
  128. };
  129. export type ParseReturnFiltered = string | MMRegExp | typeof GLOBSTAR;
  130. export type ParseReturn = ParseReturnFiltered | false;
  131. export declare class Minimatch {
  132. #private;
  133. options: MinimatchOptions;
  134. set: ParseReturnFiltered[][];
  135. pattern: string;
  136. windowsPathsNoEscape: boolean;
  137. nonegate: boolean;
  138. negate: boolean;
  139. comment: boolean;
  140. empty: boolean;
  141. preserveMultipleSlashes: boolean;
  142. partial: boolean;
  143. globSet: string[];
  144. globParts: string[][];
  145. nocase: boolean;
  146. isWindows: boolean;
  147. platform: Platform;
  148. windowsNoMagicRoot: boolean;
  149. maxGlobstarRecursion: number;
  150. regexp: false | null | MMRegExp;
  151. constructor(pattern: string, options?: MinimatchOptions);
  152. hasMagic(): boolean;
  153. debug(..._: unknown[]): void;
  154. make(): void;
  155. preprocess(globParts: string[][]): string[][];
  156. adjascentGlobstarOptimize(globParts: string[][]): string[][];
  157. levelOneOptimize(globParts: string[][]): string[][];
  158. levelTwoFileOptimize(parts: string | string[]): string[];
  159. firstPhasePreProcess(globParts: string[][]): string[][];
  160. secondPhasePreProcess(globParts: string[][]): string[][];
  161. partsMatch(a: string[], b: string[], emptyGSMatch?: boolean): false | string[];
  162. parseNegate(): void;
  163. matchOne(file: string[], pattern: ParseReturn[], partial?: boolean): boolean;
  164. braceExpand(): string[];
  165. parse(pattern: string): ParseReturn;
  166. makeRe(): false | MMRegExp;
  167. slashSplit(p: string): string[];
  168. match(f: string, partial?: boolean): boolean;
  169. static defaults(def: MinimatchOptions): typeof Minimatch;
  170. }
  171. export { AST } from './ast.js';
  172. export { escape } from './escape.js';
  173. export { unescape } from './unescape.js';
  174. //# sourceMappingURL=index.d.ts.map