4d4f2195978af10e49e142919d18872af909eb1c108cc9a36a471f7d464eed52efd3069e18c76feb767471b5422a26034bb8808a8536a0c055f6142d8db4fb-exec 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. // Type definitions for minimatch 5.1
  2. // Project: https://github.com/isaacs/minimatch
  3. // Definitions by: vvakame <https://github.com/vvakame>
  4. // Shant Marouti <https://github.com/shantmarouti>
  5. // BendingBender <https://github.com/BendingBender>
  6. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  7. /**
  8. * Tests a path against the pattern using the options.
  9. *
  10. * @example
  11. * import minimatch = require("minimatch");
  12. *
  13. * const isJS = minimatch(file, "*.js", { matchBase: true });
  14. */
  15. declare function minimatch(target: string, pattern: string, options?: minimatch.IOptions): boolean;
  16. declare namespace minimatch {
  17. /**
  18. * Match against the list of files, in the style of fnmatch or glob.
  19. * If nothing is matched, and options.nonull is set,
  20. * then return a list containing the pattern itself.
  21. *
  22. * @example
  23. * import minimatch = require("minimatch");
  24. *
  25. * const javascripts = minimatch.match(fileList, "*.js", {matchBase: true});
  26. */
  27. function match(list: readonly string[], pattern: string, options?: IOptions): string[];
  28. /**
  29. * @return A function that tests its supplied argument, suitable for use with `Array.filter`.
  30. *
  31. * @example
  32. * import minimatch = require("minimatch");
  33. *
  34. * const javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true}));
  35. */
  36. function filter(
  37. pattern: string,
  38. options?: IOptions,
  39. ): (element: string, indexed: number, array: readonly string[]) => boolean;
  40. /**
  41. * Make a regular expression object from the pattern.
  42. */
  43. function makeRe(pattern: string, options?: IOptions): RegExp | false;
  44. function defaults(defaultOptions: IOptions): typeof minimatch;
  45. function braceExpand(pattern: string, options?: IOptions): string[];
  46. const sep: string;
  47. const GLOBSTAR: unique symbol;
  48. interface IOptions {
  49. /**
  50. * Dump a ton of stuff to stderr.
  51. *
  52. * @default false
  53. */
  54. debug?: boolean | undefined;
  55. /**
  56. * Do not expand `{a,b}` and `{1..3}` brace sets.
  57. *
  58. * @default false
  59. */
  60. nobrace?: boolean | undefined;
  61. /**
  62. * Disable `**` matching against multiple folder names.
  63. *
  64. * @default false
  65. */
  66. noglobstar?: boolean | undefined;
  67. /**
  68. * Allow patterns to match filenames starting with a period,
  69. * even if the pattern does not explicitly have a period in that spot.
  70. *
  71. * Note that by default, `'a/**' + '/b'` will **not** match `a/.d/b`, unless `dot` is set.
  72. *
  73. * @default false
  74. */
  75. dot?: boolean | undefined;
  76. /**
  77. * Disable "extglob" style patterns like `+(a|b)`.
  78. *
  79. * @default false
  80. */
  81. noext?: boolean | undefined;
  82. /**
  83. * Perform a case-insensitive match.
  84. *
  85. * @default false
  86. */
  87. nocase?: boolean | undefined;
  88. /**
  89. * When a match is not found by `minimatch.match`,
  90. * return a list containing the pattern itself if this option is set.
  91. * Otherwise, an empty list is returned if there are no matches.
  92. *
  93. * @default false
  94. */
  95. nonull?: boolean | undefined;
  96. /**
  97. * If set, then patterns without slashes will be matched
  98. * against the basename of the path if it contains slashes. For example,
  99. * `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.
  100. *
  101. * @default false
  102. */
  103. matchBase?: boolean | undefined;
  104. /**
  105. * Suppress the behavior of treating `#` at the start of a pattern as a comment.
  106. *
  107. * @default false
  108. */
  109. nocomment?: boolean | undefined;
  110. /**
  111. * Suppress the behavior of treating a leading `!` character as negation.
  112. *
  113. * @default false
  114. */
  115. nonegate?: boolean | undefined;
  116. /**
  117. * Returns from negate expressions the same as if they were not negated.
  118. * (Ie, true on a hit, false on a miss.)
  119. *
  120. * @default false
  121. */
  122. flipNegate?: boolean | undefined;
  123. /**
  124. * Compare a partial path to a pattern. As long as the parts of the path that
  125. * are present are not contradicted by the pattern, it will be treated as a
  126. * match. This is useful in applications where you're walking through a
  127. * folder structure, and don't yet have the full path, but want to ensure that
  128. * you do not walk down paths that can never be a match.
  129. *
  130. * @default false
  131. *
  132. * @example
  133. * import minimatch = require("minimatch");
  134. *
  135. * minimatch('/a/b', '/a/*' + '/c/d', { partial: true }) // true, might be /a/b/c/d
  136. * minimatch('/a/b', '/**' + '/d', { partial: true }) // true, might be /a/b/.../d
  137. * minimatch('/x/y/z', '/a/**' + '/z', { partial: true }) // false, because x !== a
  138. */
  139. partial?: boolean;
  140. /**
  141. * Use `\\` as a path separator _only_, and _never_ as an escape
  142. * character. If set, all `\\` characters are replaced with `/` in
  143. * the pattern. Note that this makes it **impossible** to match
  144. * against paths containing literal glob pattern characters, but
  145. * allows matching with patterns constructed using `path.join()` and
  146. * `path.resolve()` on Windows platforms, mimicking the (buggy!)
  147. * behavior of earlier versions on Windows. Please use with
  148. * caution, and be mindful of the caveat about Windows paths
  149. *
  150. * For legacy reasons, this is also set if
  151. * `options.allowWindowsEscape` is set to the exact value `false`.
  152. *
  153. * @default false
  154. */
  155. windowsPathsNoEscape?: boolean;
  156. }
  157. /**
  158. * @deprecated Keep legacy interface to prevent unnecessary breakage.
  159. */
  160. type IMinimatchStatic = typeof Minimatch;
  161. /**
  162. * @deprecated Keep legacy interface to prevent unnecessary breakage.
  163. */
  164. type IMinimatch = Minimatch;
  165. /**
  166. * Create a minimatch object by instantiating the `minimatch.Minimatch` class.
  167. *
  168. * @example
  169. * import { Minimatch } from "minimatch";
  170. *
  171. * const mm = new Minimatch(pattern, options);
  172. */
  173. class Minimatch {
  174. constructor(pattern: string, options?: IOptions);
  175. static defaults(defaultOptions: IOptions): typeof Minimatch;
  176. /**
  177. * The original pattern the minimatch object represents.
  178. */
  179. pattern: string;
  180. /**
  181. * The options supplied to the constructor.
  182. */
  183. options: IOptions;
  184. /**
  185. * A 2-dimensional array of regexp or string expressions. Each row in the array corresponds
  186. * to a brace-expanded pattern. Each item in the row corresponds to a single path-part. For
  187. * example, the pattern `{a,b/c}/d` would expand to a set of patterns like:
  188. *
  189. * ```
  190. * [ [ a, d ]
  191. * , [ b, c, d ] ]
  192. * ```
  193. *
  194. * If a portion of the pattern doesn't have any "magic" in it (that is, it's something like `"foo"``
  195. * rather than `fo*o?`), then it will be left as a string rather than converted to a regular expression.
  196. */
  197. set: Array<Array<RegExp | string>>;
  198. /**
  199. * Created by the `makeRe` method. A single regular expression expressing the entire pattern. This is
  200. * useful in cases where you wish to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled.
  201. */
  202. regexp: RegExp | false | null;
  203. /**
  204. * True if the pattern is negated.
  205. */
  206. negate: boolean;
  207. /**
  208. * True if the pattern is a comment.
  209. */
  210. comment: boolean;
  211. /**
  212. * True if the pattern is `""`.
  213. */
  214. empty: boolean;
  215. /**
  216. * True if windows path delimiters shouldn't be interpreted as escape characters.
  217. */
  218. windowsPathsNoEscape: boolean;
  219. /**
  220. * True if partial paths should be compared to a pattern.
  221. */
  222. partial: boolean;
  223. /**
  224. * Generate the `regexp` member if necessary, and return it. Will return `false` if the pattern is invalid.
  225. */
  226. makeRe(): RegExp | false;
  227. /**
  228. * @return `true` if the filename matches the pattern, or `false` otherwise.
  229. */
  230. match(fname: string, partial?: boolean): boolean;
  231. /**
  232. * Take a `/`-split filename, and match it against a single row in the `regExpSet`.
  233. * This method is mainly for internal use, but is exposed so that it can be used
  234. * by a glob-walker that needs to avoid excessive filesystem calls.
  235. */
  236. matchOne(file: readonly string[], pattern: ReadonlyArray<string | RegExp>, partial: boolean): boolean;
  237. /**
  238. * @deprecated. For internal use.
  239. */
  240. debug(): void;
  241. /**
  242. * @deprecated. For internal use.
  243. */
  244. make(): void;
  245. /**
  246. * @deprecated. For internal use.
  247. */
  248. parseNegate(): void;
  249. /**
  250. * @deprecated. For internal use.
  251. */
  252. braceExpand(): string[];
  253. /**
  254. * @deprecated. For internal use.
  255. */
  256. parse(pattern: string, isSub?: boolean): string | false | [string, boolean] | RegExp | typeof GLOBSTAR;
  257. }
  258. }
  259. export = minimatch;