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