9e4a465ac3f76578bd83f1d4a7932dbb5dfb1970e54a1dd4c58fe9c0e6588ce378dadd7dd9981ce550673f226c41117a457ee032e9cc3ab8bf7f9f7859cb55 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // Type definitions for Minimatch 3.0
  2. // Project: https://github.com/isaacs/minimatch
  3. // Definitions by: vvakame <https://github.com/vvakame>
  4. // Shant Marouti <https://github.com/shantmarouti>
  5. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  6. /**
  7. * Tests a path against the pattern using the options.
  8. */
  9. declare function M(target: string, pattern: string, options?: M.IOptions): boolean;
  10. declare namespace M {
  11. /**
  12. * Match against the list of files, in the style of fnmatch or glob.
  13. * If nothing is matched, and options.nonull is set,
  14. * then return a list containing the pattern itself.
  15. */
  16. function match(list: string[], pattern: string, options?: IOptions): string[];
  17. /**
  18. * Returns a function that tests its supplied argument, suitable for use with Array.filter
  19. */
  20. function filter(pattern: string, options?: IOptions): (element: string, indexed: number, array: string[]) => boolean;
  21. /**
  22. * Make a regular expression object from the pattern.
  23. */
  24. function makeRe(pattern: string, options?: IOptions): RegExp;
  25. var Minimatch: IMinimatchStatic;
  26. interface IOptions {
  27. /**
  28. * Dump a ton of stuff to stderr.
  29. *
  30. * @default false
  31. */
  32. debug?: boolean;
  33. /**
  34. * Do not expand {a,b} and {1..3} brace sets.
  35. *
  36. * @default false
  37. */
  38. nobrace?: boolean;
  39. /**
  40. * Disable ** matching against multiple folder names.
  41. *
  42. * @default false
  43. */
  44. noglobstar?: boolean;
  45. /**
  46. * Allow patterns to match filenames starting with a period,
  47. * even if the pattern does not explicitly have a period in that spot.
  48. *
  49. * @default false
  50. */
  51. dot?: boolean;
  52. /**
  53. * Disable "extglob" style patterns like +(a|b).
  54. *
  55. * @default false
  56. */
  57. noext?: boolean;
  58. /**
  59. * Perform a case-insensitive match.
  60. *
  61. * @default false
  62. */
  63. nocase?: boolean;
  64. /**
  65. * When a match is not found by minimatch.match,
  66. * return a list containing the pattern itself if this option is set.
  67. * Otherwise, an empty list is returned if there are no matches.
  68. *
  69. * @default false
  70. */
  71. nonull?: boolean;
  72. /**
  73. * If set, then patterns without slashes will be matched against
  74. * the basename of the path if it contains slashes.
  75. *
  76. * @default false
  77. */
  78. matchBase?: boolean;
  79. /**
  80. * Suppress the behavior of treating #
  81. * at the start of a pattern as a comment.
  82. *
  83. * @default false
  84. */
  85. nocomment?: boolean;
  86. /**
  87. * Suppress the behavior of treating a leading ! character as negation.
  88. *
  89. * @default false
  90. */
  91. nonegate?: boolean;
  92. /**
  93. * Returns from negate expressions the same as if they were not negated.
  94. * (Ie, true on a hit, false on a miss.)
  95. *
  96. * @default false
  97. */
  98. flipNegate?: boolean;
  99. }
  100. interface IMinimatchStatic {
  101. new(pattern: string, options?: IOptions): IMinimatch;
  102. prototype: IMinimatch;
  103. }
  104. interface IMinimatch {
  105. /**
  106. * The original pattern the minimatch object represents.
  107. */
  108. pattern: string;
  109. /**
  110. * The options supplied to the constructor.
  111. */
  112. options: IOptions;
  113. /**
  114. * A 2-dimensional array of regexp or string expressions.
  115. */
  116. set: any[][]; // (RegExp | string)[][]
  117. /**
  118. * A single regular expression expressing the entire pattern.
  119. * Created by the makeRe method.
  120. */
  121. regexp: RegExp;
  122. /**
  123. * True if the pattern is negated.
  124. */
  125. negate: boolean;
  126. /**
  127. * True if the pattern is a comment.
  128. */
  129. comment: boolean;
  130. /**
  131. * True if the pattern is ""
  132. */
  133. empty: boolean;
  134. /**
  135. * Generate the regexp member if necessary, and return it.
  136. * Will return false if the pattern is invalid.
  137. */
  138. makeRe(): RegExp; // regexp or boolean
  139. /**
  140. * Return true if the filename matches the pattern, or false otherwise.
  141. */
  142. match(fname: string): boolean;
  143. /**
  144. * Take a /-split filename, and match it against a single row in the regExpSet.
  145. * This method is mainly for internal use, but is exposed so that it can be used
  146. * by a glob-walker that needs to avoid excessive filesystem calls.
  147. */
  148. matchOne(files: string[], pattern: string[], partial: boolean): boolean;
  149. /**
  150. * Deprecated. For internal use.
  151. *
  152. * @private
  153. */
  154. debug(): void;
  155. /**
  156. * Deprecated. For internal use.
  157. *
  158. * @private
  159. */
  160. make(): void;
  161. /**
  162. * Deprecated. For internal use.
  163. *
  164. * @private
  165. */
  166. parseNegate(): void;
  167. /**
  168. * Deprecated. For internal use.
  169. *
  170. * @private
  171. */
  172. braceExpand(pattern: string, options: IOptions): void;
  173. /**
  174. * Deprecated. For internal use.
  175. *
  176. * @private
  177. */
  178. parse(pattern: string, isSub?: boolean): void;
  179. }
  180. }
  181. export = M;