cspell-glob 9.6.0 → 9.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +202 -3
- package/dist/index.js +555 -3
- package/package.json +8 -8
- package/dist/GlobMatcher.d.ts +0 -101
- package/dist/GlobMatcher.js +0 -190
- package/dist/GlobMatcherTypes.d.ts +0 -63
- package/dist/GlobMatcherTypes.js +0 -3
- package/dist/globHelper.d.ts +0 -87
- package/dist/globHelper.js +0 -450
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,203 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/GlobMatcherTypes.d.ts
|
|
2
|
+
interface PathInterface {
|
|
3
|
+
normalize(p: string): string;
|
|
4
|
+
join(...paths: string[]): string;
|
|
5
|
+
resolve(...paths: string[]): string;
|
|
6
|
+
relative(from: string, to: string): string;
|
|
7
|
+
isAbsolute(p: string): boolean;
|
|
8
|
+
parse(p: string): {
|
|
9
|
+
root: string;
|
|
10
|
+
dir: string;
|
|
11
|
+
base: string;
|
|
12
|
+
ext: string;
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
sep: string;
|
|
16
|
+
}
|
|
17
|
+
type GlobMatch = GlobMatchRule | GlobMatchNoRule;
|
|
18
|
+
interface GlobMatchRule {
|
|
19
|
+
matched: boolean;
|
|
20
|
+
glob: string;
|
|
21
|
+
root: string;
|
|
22
|
+
pattern: GlobPatternWithRoot;
|
|
23
|
+
index: number;
|
|
24
|
+
isNeg: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface GlobMatchNoRule {
|
|
27
|
+
matched: false;
|
|
28
|
+
}
|
|
29
|
+
type GlobPattern = SimpleGlobPattern | GlobPatternWithRoot | GlobPatternWithOptionalRoot;
|
|
30
|
+
type SimpleGlobPattern = string;
|
|
31
|
+
interface GlobPatternWithOptionalRoot {
|
|
32
|
+
/**
|
|
33
|
+
* a glob pattern
|
|
34
|
+
*/
|
|
35
|
+
glob: string;
|
|
36
|
+
/**
|
|
37
|
+
* The root from which the glob pattern is relative.
|
|
38
|
+
* @default: options.root
|
|
39
|
+
*/
|
|
40
|
+
root?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Optional value useful for tracing which file a glob pattern was defined in.
|
|
43
|
+
*/
|
|
44
|
+
source?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Optional line number in the source
|
|
47
|
+
*/
|
|
48
|
+
line?: number | undefined;
|
|
49
|
+
}
|
|
50
|
+
interface GlobPatternWithRoot extends GlobPatternWithOptionalRoot {
|
|
51
|
+
root: string;
|
|
52
|
+
/**
|
|
53
|
+
* Global patterns do not need to be relative to the root.
|
|
54
|
+
* Note: Some patterns start with `**` but they are tied to the root. In this case, `isGlobalPattern` is `false`.
|
|
55
|
+
*/
|
|
56
|
+
isGlobalPattern: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface GlobPatternNormalized extends GlobPatternWithRoot {
|
|
59
|
+
/** the original glob pattern before it was normalized */
|
|
60
|
+
rawGlob: string;
|
|
61
|
+
/** the original root */
|
|
62
|
+
rawRoot: string | undefined;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/globHelper.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* This function tries its best to determine if `fileOrGlob` is a path to a file or a glob pattern.
|
|
68
|
+
* @param fileOrGlob - file (with absolute path) or glob.
|
|
69
|
+
* @param root - absolute path to the directory that will be considered the root when testing the glob pattern.
|
|
70
|
+
* @param path - optional node path methods - used for testing
|
|
71
|
+
*/
|
|
72
|
+
declare function fileOrGlobToGlob(fileOrGlob: string | GlobPattern, root: string, path?: PathInterface): GlobPatternWithRoot;
|
|
73
|
+
declare function isGlobPatternWithOptionalRoot(g: GlobPattern): g is GlobPatternWithOptionalRoot;
|
|
74
|
+
declare function isGlobPatternWithRoot(g: GlobPattern): g is GlobPatternWithRoot;
|
|
75
|
+
declare function isGlobPatternNormalized(g: GlobPattern | GlobPatternNormalized): g is GlobPatternNormalized;
|
|
76
|
+
interface NormalizeOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Indicates that the glob should be modified to match nested patterns.
|
|
79
|
+
*
|
|
80
|
+
* Example: `node_modules` becomes `**/node_modules/**`, `**/node_modules`, and `node_modules/**`
|
|
81
|
+
*/
|
|
82
|
+
nested: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* This is the root to use for the glob if the glob does not already contain one.
|
|
85
|
+
*/
|
|
86
|
+
root: string;
|
|
87
|
+
/**
|
|
88
|
+
* This is the replacement for `${cwd}` in either the root or in the glob.
|
|
89
|
+
*/
|
|
90
|
+
cwd?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Optional path interface for working with paths.
|
|
93
|
+
*/
|
|
94
|
+
nodePath?: PathInterface;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param patterns - glob patterns to normalize.
|
|
99
|
+
* @param options - Normalization options.
|
|
100
|
+
*/
|
|
101
|
+
declare function normalizeGlobPatterns(patterns: GlobPattern[], options: NormalizeOptions): GlobPatternNormalized[];
|
|
102
|
+
declare function workaroundPicomatchBug(glob: string): string;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/GlobMatcher.d.ts
|
|
105
|
+
type Optional<T> = { [P in keyof T]?: T[P] | undefined };
|
|
106
|
+
type GlobMatchOptions = Optional<NormalizedGlobMatchOptions>;
|
|
107
|
+
type MatcherMode = 'exclude' | 'include';
|
|
108
|
+
interface NormalizedGlobMatchOptions {
|
|
109
|
+
/**
|
|
110
|
+
* The matcher has two modes (`include` or `exclude`) that impact how globs behave.
|
|
111
|
+
*
|
|
112
|
+
* `include` - designed for searching for file. By default it matches a sub-set of file.
|
|
113
|
+
* In include mode, the globs need to be more explicit to match.
|
|
114
|
+
* - `dot` is by default false.
|
|
115
|
+
* - `nested` is by default false.
|
|
116
|
+
*
|
|
117
|
+
* `exclude` - designed to emulate `.gitignore`. By default it matches a larger range of files.
|
|
118
|
+
* - `dot` is by default true.
|
|
119
|
+
* - `nested` is by default true.
|
|
120
|
+
*
|
|
121
|
+
* @default: 'exclude'
|
|
122
|
+
*/
|
|
123
|
+
mode: MatcherMode;
|
|
124
|
+
/**
|
|
125
|
+
* The default directory from which a glob is relative.
|
|
126
|
+
* Any globs that are not relative to the root will ignored.
|
|
127
|
+
* @default: process.cwd()
|
|
128
|
+
*/
|
|
129
|
+
root: string;
|
|
130
|
+
/**
|
|
131
|
+
* The directory to use as the current working directory.
|
|
132
|
+
* @default: process.cwd();
|
|
133
|
+
*/
|
|
134
|
+
cwd: string;
|
|
135
|
+
/**
|
|
136
|
+
* Allows matching against directories with a leading `.`.
|
|
137
|
+
*
|
|
138
|
+
* @default: mode == 'exclude'
|
|
139
|
+
*/
|
|
140
|
+
dot: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Allows matching against nested directories or files without needing to add `**`
|
|
143
|
+
*
|
|
144
|
+
* @default: mode == 'exclude'
|
|
145
|
+
*/
|
|
146
|
+
nested: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Mostly used for testing purposes. It allows explicitly specifying `path.win32` or `path.posix`.
|
|
149
|
+
*
|
|
150
|
+
* @default: require('path')
|
|
151
|
+
*/
|
|
152
|
+
nodePath: PathInterface;
|
|
153
|
+
/**
|
|
154
|
+
* Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters.
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
nobrace?: boolean | undefined;
|
|
159
|
+
}
|
|
160
|
+
declare class GlobMatcher {
|
|
161
|
+
/**
|
|
162
|
+
* @param filename full path of file to match against.
|
|
163
|
+
* @returns a GlobMatch - information about the match.
|
|
164
|
+
*/
|
|
165
|
+
readonly matchEx: (filename: string) => GlobMatch;
|
|
166
|
+
readonly path: PathInterface;
|
|
167
|
+
readonly patterns: GlobPatternWithRoot[];
|
|
168
|
+
readonly patternsNormalizedToRoot: GlobPatternNormalized[];
|
|
169
|
+
/**
|
|
170
|
+
* path or href of the root directory.
|
|
171
|
+
*/
|
|
172
|
+
readonly root: string;
|
|
173
|
+
readonly dot: boolean;
|
|
174
|
+
readonly options: NormalizedGlobMatchOptions;
|
|
175
|
+
/**
|
|
176
|
+
* Instance ID
|
|
177
|
+
*/
|
|
178
|
+
readonly id: number;
|
|
179
|
+
/**
|
|
180
|
+
* Construct a `.gitignore` emulator
|
|
181
|
+
* @param patterns - the contents of a `.gitignore` style file or an array of individual glob rules.
|
|
182
|
+
* @param root - the working directory
|
|
183
|
+
*/
|
|
184
|
+
constructor(patterns: GlobPattern | GlobPattern[], root?: string | URL, nodePath?: PathInterface);
|
|
185
|
+
/**
|
|
186
|
+
* Construct a `.gitignore` emulator
|
|
187
|
+
* @param patterns - the contents of a `.gitignore` style file or an array of individual glob rules.
|
|
188
|
+
* @param options - to set the root and other options
|
|
189
|
+
*/
|
|
190
|
+
constructor(patterns: GlobPattern | GlobPattern[], options?: GlobMatchOptions);
|
|
191
|
+
constructor(patterns: GlobPattern | GlobPattern[], rootOrOptions?: string | URL | GlobMatchOptions);
|
|
192
|
+
/**
|
|
193
|
+
* Check to see if a filename matches any of the globs.
|
|
194
|
+
* If filename is relative, it is considered relative to the root.
|
|
195
|
+
* If filename is absolute and contained within the root, it will be made relative before being tested for a glob match.
|
|
196
|
+
* If filename is absolute and not contained within the root, it will be tested as is.
|
|
197
|
+
* @param filename full path of the file to check.
|
|
198
|
+
*/
|
|
199
|
+
match(filename: string): boolean;
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
export { GlobMatch, GlobMatchNoRule, type GlobMatchOptions, GlobMatchRule, GlobMatcher, GlobPattern, GlobPatternNormalized, GlobPatternWithOptionalRoot, GlobPatternWithRoot, type NormalizeOptions, PathInterface, SimpleGlobPattern, fileOrGlobToGlob, isGlobPatternNormalized, isGlobPatternWithOptionalRoot, isGlobPatternWithRoot, normalizeGlobPatterns, workaroundPicomatchBug };
|
|
4
203
|
//# sourceMappingURL=index.d.ts.map
|