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