@volar/typescript 1.6.9 → 1.7.1-patch.1
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/out/documentRegistry.d.ts +2 -0
- package/out/documentRegistry.js +14 -0
- package/out/dtsHost.d.ts +26 -0
- package/out/dtsHost.js +190 -0
- package/out/getProgram.d.ts +1 -1
- package/out/getProgram.js +8 -8
- package/out/index.d.ts +5 -8
- package/out/index.js +19 -285
- package/out/languageService.d.ts +9 -0
- package/out/languageService.js +292 -0
- package/out/languageServiceHost.d.ts +5 -0
- package/out/languageServiceHost.js +210 -0
- package/out/sys.d.ts +7 -0
- package/out/sys.js +327 -0
- package/out/typescript/core.d.ts +83 -0
- package/out/typescript/core.js +320 -0
- package/out/typescript/corePublic.d.ts +91 -0
- package/out/typescript/corePublic.js +51 -0
- package/out/typescript/path.d.ts +112 -0
- package/out/typescript/path.js +417 -0
- package/out/typescript/types.d.ts +129 -0
- package/out/typescript/types.js +3 -0
- package/out/typescript/utilities.d.ts +7 -0
- package/out/typescript/utilities.js +250 -0
- package/package.json +5 -3
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containsPath = exports.removeTrailingDirectorySeparator = exports.normalizePath = exports.getNormalizedPathComponents = exports.combinePaths = exports.getDirectoryPath = exports.fileExtensionIsOneOf = exports.hasExtension = exports.isRootedDiskPath = exports.directorySeparator = void 0;
|
|
4
|
+
const core_1 = require("./core");
|
|
5
|
+
/**
|
|
6
|
+
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
7
|
+
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
8
|
+
* we expect the host to correctly handle paths in our specified format.
|
|
9
|
+
*/
|
|
10
|
+
exports.directorySeparator = "/";
|
|
11
|
+
const altDirectorySeparator = "\\";
|
|
12
|
+
const urlSchemeSeparator = "://";
|
|
13
|
+
const backslashRegExp = /\\/g;
|
|
14
|
+
//// Path Tests
|
|
15
|
+
/**
|
|
16
|
+
* Determines whether a charCode corresponds to `/` or `\`.
|
|
17
|
+
*/
|
|
18
|
+
function isAnyDirectorySeparator(charCode) {
|
|
19
|
+
return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
|
|
23
|
+
* like `c:`, `c:\` or `c:/`).
|
|
24
|
+
*/
|
|
25
|
+
function isRootedDiskPath(path) {
|
|
26
|
+
return getEncodedRootLength(path) > 0;
|
|
27
|
+
}
|
|
28
|
+
exports.isRootedDiskPath = isRootedDiskPath;
|
|
29
|
+
function hasExtension(fileName) {
|
|
30
|
+
return (0, core_1.stringContains)(getBaseFileName(fileName), ".");
|
|
31
|
+
}
|
|
32
|
+
exports.hasExtension = hasExtension;
|
|
33
|
+
function fileExtensionIs(path, extension) {
|
|
34
|
+
return path.length > extension.length && (0, core_1.endsWith)(path, extension);
|
|
35
|
+
}
|
|
36
|
+
function fileExtensionIsOneOf(path, extensions) {
|
|
37
|
+
for (const extension of extensions) {
|
|
38
|
+
if (fileExtensionIs(path, extension)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
exports.fileExtensionIsOneOf = fileExtensionIsOneOf;
|
|
45
|
+
/**
|
|
46
|
+
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
47
|
+
*/
|
|
48
|
+
function hasTrailingDirectorySeparator(path) {
|
|
49
|
+
return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
|
|
50
|
+
}
|
|
51
|
+
//// Path Parsing
|
|
52
|
+
function isVolumeCharacter(charCode) {
|
|
53
|
+
return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) ||
|
|
54
|
+
(charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */);
|
|
55
|
+
}
|
|
56
|
+
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
57
|
+
const ch0 = url.charCodeAt(start);
|
|
58
|
+
if (ch0 === 58 /* CharacterCodes.colon */)
|
|
59
|
+
return start + 1;
|
|
60
|
+
if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) {
|
|
61
|
+
const ch2 = url.charCodeAt(start + 2);
|
|
62
|
+
if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */)
|
|
63
|
+
return start + 3;
|
|
64
|
+
}
|
|
65
|
+
return -1;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
69
|
+
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
70
|
+
*/
|
|
71
|
+
function getEncodedRootLength(path) {
|
|
72
|
+
if (!path)
|
|
73
|
+
return 0;
|
|
74
|
+
const ch0 = path.charCodeAt(0);
|
|
75
|
+
// POSIX or UNC
|
|
76
|
+
if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) {
|
|
77
|
+
if (path.charCodeAt(1) !== ch0)
|
|
78
|
+
return 1; // POSIX: "/" (or non-normalized "\")
|
|
79
|
+
const p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? exports.directorySeparator : altDirectorySeparator, 2);
|
|
80
|
+
if (p1 < 0)
|
|
81
|
+
return path.length; // UNC: "//server" or "\\server"
|
|
82
|
+
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
83
|
+
}
|
|
84
|
+
// DOS
|
|
85
|
+
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) {
|
|
86
|
+
const ch2 = path.charCodeAt(2);
|
|
87
|
+
if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */)
|
|
88
|
+
return 3; // DOS: "c:/" or "c:\"
|
|
89
|
+
if (path.length === 2)
|
|
90
|
+
return 2; // DOS: "c:" (but not "c:d")
|
|
91
|
+
}
|
|
92
|
+
// URL
|
|
93
|
+
const schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
94
|
+
if (schemeEnd !== -1) {
|
|
95
|
+
const authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
96
|
+
const authorityEnd = path.indexOf(exports.directorySeparator, authorityStart);
|
|
97
|
+
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
98
|
+
// For local "file" URLs, include the leading DOS volume (if present).
|
|
99
|
+
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
100
|
+
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
101
|
+
const scheme = path.slice(0, schemeEnd);
|
|
102
|
+
const authority = path.slice(authorityStart, authorityEnd);
|
|
103
|
+
if (scheme === "file" && (authority === "" || authority === "localhost") &&
|
|
104
|
+
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
105
|
+
const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
106
|
+
if (volumeSeparatorEnd !== -1) {
|
|
107
|
+
if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) {
|
|
108
|
+
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
109
|
+
return ~(volumeSeparatorEnd + 1);
|
|
110
|
+
}
|
|
111
|
+
if (volumeSeparatorEnd === path.length) {
|
|
112
|
+
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
113
|
+
// but not "file:///c:d" or "file:///c%3ad"
|
|
114
|
+
return ~volumeSeparatorEnd;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
119
|
+
}
|
|
120
|
+
return ~path.length; // URL: "file://server", "http://server"
|
|
121
|
+
}
|
|
122
|
+
// relative
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
127
|
+
*
|
|
128
|
+
* For example:
|
|
129
|
+
* ```ts
|
|
130
|
+
* getRootLength("a") === 0 // ""
|
|
131
|
+
* getRootLength("/") === 1 // "/"
|
|
132
|
+
* getRootLength("c:") === 2 // "c:"
|
|
133
|
+
* getRootLength("c:d") === 0 // ""
|
|
134
|
+
* getRootLength("c:/") === 3 // "c:/"
|
|
135
|
+
* getRootLength("c:\\") === 3 // "c:\\"
|
|
136
|
+
* getRootLength("//server") === 7 // "//server"
|
|
137
|
+
* getRootLength("//server/share") === 8 // "//server/"
|
|
138
|
+
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
139
|
+
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
140
|
+
* getRootLength("file:///path") === 8 // "file:///"
|
|
141
|
+
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
142
|
+
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
143
|
+
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
144
|
+
* getRootLength("file://server") === 13 // "file://server"
|
|
145
|
+
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
146
|
+
* getRootLength("http://server") === 13 // "http://server"
|
|
147
|
+
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
function getRootLength(path) {
|
|
151
|
+
const rootLength = getEncodedRootLength(path);
|
|
152
|
+
return rootLength < 0 ? ~rootLength : rootLength;
|
|
153
|
+
}
|
|
154
|
+
function getDirectoryPath(path) {
|
|
155
|
+
path = normalizeSlashes(path);
|
|
156
|
+
// If the path provided is itself the root, then return it.
|
|
157
|
+
const rootLength = getRootLength(path);
|
|
158
|
+
if (rootLength === path.length)
|
|
159
|
+
return path;
|
|
160
|
+
// return the leading portion of the path up to the last (non-terminal) directory separator
|
|
161
|
+
// but not including any trailing directory separator.
|
|
162
|
+
path = removeTrailingDirectorySeparator(path);
|
|
163
|
+
return path.slice(0, Math.max(rootLength, path.lastIndexOf(exports.directorySeparator)));
|
|
164
|
+
}
|
|
165
|
+
exports.getDirectoryPath = getDirectoryPath;
|
|
166
|
+
function getBaseFileName(path, extensions, ignoreCase) {
|
|
167
|
+
path = normalizeSlashes(path);
|
|
168
|
+
// if the path provided is itself the root, then it has not file name.
|
|
169
|
+
const rootLength = getRootLength(path);
|
|
170
|
+
if (rootLength === path.length)
|
|
171
|
+
return "";
|
|
172
|
+
// return the trailing portion of the path starting after the last (non-terminal) directory
|
|
173
|
+
// separator but not including any trailing directory separator.
|
|
174
|
+
path = removeTrailingDirectorySeparator(path);
|
|
175
|
+
const name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(exports.directorySeparator) + 1));
|
|
176
|
+
const extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
|
|
177
|
+
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
178
|
+
}
|
|
179
|
+
function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
|
|
180
|
+
if (!(0, core_1.startsWith)(extension, "."))
|
|
181
|
+
extension = "." + extension;
|
|
182
|
+
if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) {
|
|
183
|
+
const pathExtension = path.slice(path.length - extension.length);
|
|
184
|
+
if (stringEqualityComparer(pathExtension, extension)) {
|
|
185
|
+
return pathExtension;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
|
|
190
|
+
if (typeof extensions === "string") {
|
|
191
|
+
return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
|
|
192
|
+
}
|
|
193
|
+
for (const extension of extensions) {
|
|
194
|
+
const result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
|
|
195
|
+
if (result)
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
return "";
|
|
199
|
+
}
|
|
200
|
+
function getAnyExtensionFromPath(path, extensions, ignoreCase) {
|
|
201
|
+
// Retrieves any string from the final "." onwards from a base file name.
|
|
202
|
+
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
|
203
|
+
if (extensions) {
|
|
204
|
+
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? core_1.equateStringsCaseInsensitive : core_1.equateStringsCaseSensitive);
|
|
205
|
+
}
|
|
206
|
+
const baseFileName = getBaseFileName(path);
|
|
207
|
+
const extensionIndex = baseFileName.lastIndexOf(".");
|
|
208
|
+
if (extensionIndex >= 0) {
|
|
209
|
+
return baseFileName.substring(extensionIndex);
|
|
210
|
+
}
|
|
211
|
+
return "";
|
|
212
|
+
}
|
|
213
|
+
function pathComponents(path, rootLength) {
|
|
214
|
+
const root = path.substring(0, rootLength);
|
|
215
|
+
const rest = path.substring(rootLength).split(exports.directorySeparator);
|
|
216
|
+
if (rest.length && !(0, core_1.lastOrUndefined)(rest))
|
|
217
|
+
rest.pop();
|
|
218
|
+
return [root, ...rest];
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
222
|
+
* components (at indices > 0). The result is not normalized.
|
|
223
|
+
* If the path is relative, the root component is `""`.
|
|
224
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
225
|
+
*
|
|
226
|
+
* ```ts
|
|
227
|
+
* // POSIX
|
|
228
|
+
* getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
|
|
229
|
+
* getPathComponents("/path/to/") === ["/", "path", "to"]
|
|
230
|
+
* getPathComponents("/") === ["/"]
|
|
231
|
+
* // DOS
|
|
232
|
+
* getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
|
|
233
|
+
* getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
|
|
234
|
+
* getPathComponents("c:/") === ["c:/"]
|
|
235
|
+
* getPathComponents("c:") === ["c:"]
|
|
236
|
+
* // URL
|
|
237
|
+
* getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
|
|
238
|
+
* getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
|
|
239
|
+
* getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
|
|
240
|
+
* getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
|
|
241
|
+
* getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
|
|
242
|
+
* getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
|
|
243
|
+
* getPathComponents("file://server/") === ["file://server/"]
|
|
244
|
+
* getPathComponents("file://server") === ["file://server"]
|
|
245
|
+
* getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
|
|
246
|
+
* getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
|
|
247
|
+
* getPathComponents("file:///") === ["file:///"]
|
|
248
|
+
* getPathComponents("file://") === ["file://"]
|
|
249
|
+
*/
|
|
250
|
+
function getPathComponents(path, currentDirectory = "") {
|
|
251
|
+
path = combinePaths(currentDirectory, path);
|
|
252
|
+
return pathComponents(path, getRootLength(path));
|
|
253
|
+
}
|
|
254
|
+
//// Path Formatting
|
|
255
|
+
/**
|
|
256
|
+
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
|
257
|
+
* segments (at indices > 0).
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
function getPathFromPathComponents(pathComponents) {
|
|
264
|
+
if (pathComponents.length === 0)
|
|
265
|
+
return "";
|
|
266
|
+
const root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
|
267
|
+
return root + pathComponents.slice(1).join(exports.directorySeparator);
|
|
268
|
+
}
|
|
269
|
+
//// Path Normalization
|
|
270
|
+
/**
|
|
271
|
+
* Normalize path separators, converting `\` into `/`.
|
|
272
|
+
*/
|
|
273
|
+
function normalizeSlashes(path) {
|
|
274
|
+
return path.indexOf("\\") !== -1
|
|
275
|
+
? path.replace(backslashRegExp, exports.directorySeparator)
|
|
276
|
+
: path;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Reduce an array of path components to a more simplified path by navigating any
|
|
280
|
+
* `"."` or `".."` entries in the path.
|
|
281
|
+
*/
|
|
282
|
+
function reducePathComponents(components) {
|
|
283
|
+
if (!(0, core_1.some)(components))
|
|
284
|
+
return [];
|
|
285
|
+
const reduced = [components[0]];
|
|
286
|
+
for (let i = 1; i < components.length; i++) {
|
|
287
|
+
const component = components[i];
|
|
288
|
+
if (!component)
|
|
289
|
+
continue;
|
|
290
|
+
if (component === ".")
|
|
291
|
+
continue;
|
|
292
|
+
if (component === "..") {
|
|
293
|
+
if (reduced.length > 1) {
|
|
294
|
+
if (reduced[reduced.length - 1] !== "..") {
|
|
295
|
+
reduced.pop();
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else if (reduced[0])
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
reduced.push(component);
|
|
303
|
+
}
|
|
304
|
+
return reduced;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Non-rooted
|
|
311
|
+
* combinePaths("path", "to", "file.ext") === "path/to/file.ext"
|
|
312
|
+
* combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
|
|
313
|
+
* // POSIX
|
|
314
|
+
* combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
|
|
315
|
+
* combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
|
|
316
|
+
* // DOS
|
|
317
|
+
* combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
|
|
318
|
+
* combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
|
|
319
|
+
* // URL
|
|
320
|
+
* combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
|
|
321
|
+
* combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
function combinePaths(path, ...paths) {
|
|
325
|
+
if (path)
|
|
326
|
+
path = normalizeSlashes(path);
|
|
327
|
+
for (let relativePath of paths) {
|
|
328
|
+
if (!relativePath)
|
|
329
|
+
continue;
|
|
330
|
+
relativePath = normalizeSlashes(relativePath);
|
|
331
|
+
if (!path || getRootLength(relativePath) !== 0) {
|
|
332
|
+
path = relativePath;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return path;
|
|
339
|
+
}
|
|
340
|
+
exports.combinePaths = combinePaths;
|
|
341
|
+
/**
|
|
342
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
343
|
+
* components (at indices > 0). The result is normalized.
|
|
344
|
+
* If the path is relative, the root component is `""`.
|
|
345
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
346
|
+
*
|
|
347
|
+
* ```ts
|
|
348
|
+
* getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
function getNormalizedPathComponents(path, currentDirectory) {
|
|
352
|
+
return reducePathComponents(getPathComponents(path, currentDirectory));
|
|
353
|
+
}
|
|
354
|
+
exports.getNormalizedPathComponents = getNormalizedPathComponents;
|
|
355
|
+
function normalizePath(path) {
|
|
356
|
+
path = normalizeSlashes(path);
|
|
357
|
+
// Most paths don't require normalization
|
|
358
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
359
|
+
return path;
|
|
360
|
+
}
|
|
361
|
+
// Some paths only require cleanup of `/./` or leading `./`
|
|
362
|
+
const simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
|
|
363
|
+
if (simplified !== path) {
|
|
364
|
+
path = simplified;
|
|
365
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
366
|
+
return path;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// Other paths require full normalization
|
|
370
|
+
const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
|
|
371
|
+
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
372
|
+
}
|
|
373
|
+
exports.normalizePath = normalizePath;
|
|
374
|
+
function removeTrailingDirectorySeparator(path) {
|
|
375
|
+
if (hasTrailingDirectorySeparator(path)) {
|
|
376
|
+
return path.substr(0, path.length - 1);
|
|
377
|
+
}
|
|
378
|
+
return path;
|
|
379
|
+
}
|
|
380
|
+
exports.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
|
|
381
|
+
function ensureTrailingDirectorySeparator(path) {
|
|
382
|
+
if (!hasTrailingDirectorySeparator(path)) {
|
|
383
|
+
return path + exports.directorySeparator;
|
|
384
|
+
}
|
|
385
|
+
return path;
|
|
386
|
+
}
|
|
387
|
+
//// Path Comparisons
|
|
388
|
+
// check path for these segments: '', '.'. '..'
|
|
389
|
+
const relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
|
390
|
+
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
391
|
+
if (typeof currentDirectory === "string") {
|
|
392
|
+
parent = combinePaths(currentDirectory, parent);
|
|
393
|
+
child = combinePaths(currentDirectory, child);
|
|
394
|
+
}
|
|
395
|
+
else if (typeof currentDirectory === "boolean") {
|
|
396
|
+
ignoreCase = currentDirectory;
|
|
397
|
+
}
|
|
398
|
+
if (parent === undefined || child === undefined)
|
|
399
|
+
return false;
|
|
400
|
+
if (parent === child)
|
|
401
|
+
return true;
|
|
402
|
+
const parentComponents = reducePathComponents(getPathComponents(parent));
|
|
403
|
+
const childComponents = reducePathComponents(getPathComponents(child));
|
|
404
|
+
if (childComponents.length < parentComponents.length) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
const componentEqualityComparer = ignoreCase ? core_1.equateStringsCaseInsensitive : core_1.equateStringsCaseSensitive;
|
|
408
|
+
for (let i = 0; i < parentComponents.length; i++) {
|
|
409
|
+
const equalityComparer = i === 0 ? core_1.equateStringsCaseInsensitive : componentEqualityComparer;
|
|
410
|
+
if (!equalityComparer(parentComponents[i], childComponents[i])) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
exports.containsPath = containsPath;
|
|
417
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export type Path = string & {
|
|
2
|
+
__pathBrand: any;
|
|
3
|
+
};
|
|
4
|
+
export declare const enum CharacterCodes {
|
|
5
|
+
nullCharacter = 0,
|
|
6
|
+
maxAsciiCharacter = 127,
|
|
7
|
+
lineFeed = 10,
|
|
8
|
+
carriageReturn = 13,
|
|
9
|
+
lineSeparator = 8232,
|
|
10
|
+
paragraphSeparator = 8233,
|
|
11
|
+
nextLine = 133,
|
|
12
|
+
space = 32,
|
|
13
|
+
nonBreakingSpace = 160,
|
|
14
|
+
enQuad = 8192,
|
|
15
|
+
emQuad = 8193,
|
|
16
|
+
enSpace = 8194,
|
|
17
|
+
emSpace = 8195,
|
|
18
|
+
threePerEmSpace = 8196,
|
|
19
|
+
fourPerEmSpace = 8197,
|
|
20
|
+
sixPerEmSpace = 8198,
|
|
21
|
+
figureSpace = 8199,
|
|
22
|
+
punctuationSpace = 8200,
|
|
23
|
+
thinSpace = 8201,
|
|
24
|
+
hairSpace = 8202,
|
|
25
|
+
zeroWidthSpace = 8203,
|
|
26
|
+
narrowNoBreakSpace = 8239,
|
|
27
|
+
ideographicSpace = 12288,
|
|
28
|
+
mathematicalSpace = 8287,
|
|
29
|
+
ogham = 5760,
|
|
30
|
+
_ = 95,
|
|
31
|
+
$ = 36,
|
|
32
|
+
_0 = 48,
|
|
33
|
+
_1 = 49,
|
|
34
|
+
_2 = 50,
|
|
35
|
+
_3 = 51,
|
|
36
|
+
_4 = 52,
|
|
37
|
+
_5 = 53,
|
|
38
|
+
_6 = 54,
|
|
39
|
+
_7 = 55,
|
|
40
|
+
_8 = 56,
|
|
41
|
+
_9 = 57,
|
|
42
|
+
a = 97,
|
|
43
|
+
b = 98,
|
|
44
|
+
c = 99,
|
|
45
|
+
d = 100,
|
|
46
|
+
e = 101,
|
|
47
|
+
f = 102,
|
|
48
|
+
g = 103,
|
|
49
|
+
h = 104,
|
|
50
|
+
i = 105,
|
|
51
|
+
j = 106,
|
|
52
|
+
k = 107,
|
|
53
|
+
l = 108,
|
|
54
|
+
m = 109,
|
|
55
|
+
n = 110,
|
|
56
|
+
o = 111,
|
|
57
|
+
p = 112,
|
|
58
|
+
q = 113,
|
|
59
|
+
r = 114,
|
|
60
|
+
s = 115,
|
|
61
|
+
t = 116,
|
|
62
|
+
u = 117,
|
|
63
|
+
v = 118,
|
|
64
|
+
w = 119,
|
|
65
|
+
x = 120,
|
|
66
|
+
y = 121,
|
|
67
|
+
z = 122,
|
|
68
|
+
A = 65,
|
|
69
|
+
B = 66,
|
|
70
|
+
C = 67,
|
|
71
|
+
D = 68,
|
|
72
|
+
E = 69,
|
|
73
|
+
F = 70,
|
|
74
|
+
G = 71,
|
|
75
|
+
H = 72,
|
|
76
|
+
I = 73,
|
|
77
|
+
J = 74,
|
|
78
|
+
K = 75,
|
|
79
|
+
L = 76,
|
|
80
|
+
M = 77,
|
|
81
|
+
N = 78,
|
|
82
|
+
O = 79,
|
|
83
|
+
P = 80,
|
|
84
|
+
Q = 81,
|
|
85
|
+
R = 82,
|
|
86
|
+
S = 83,
|
|
87
|
+
T = 84,
|
|
88
|
+
U = 85,
|
|
89
|
+
V = 86,
|
|
90
|
+
W = 87,
|
|
91
|
+
X = 88,
|
|
92
|
+
Y = 89,
|
|
93
|
+
Z = 90,
|
|
94
|
+
ampersand = 38,
|
|
95
|
+
asterisk = 42,
|
|
96
|
+
at = 64,
|
|
97
|
+
backslash = 92,
|
|
98
|
+
backtick = 96,
|
|
99
|
+
bar = 124,
|
|
100
|
+
caret = 94,
|
|
101
|
+
closeBrace = 125,
|
|
102
|
+
closeBracket = 93,
|
|
103
|
+
closeParen = 41,
|
|
104
|
+
colon = 58,
|
|
105
|
+
comma = 44,
|
|
106
|
+
dot = 46,
|
|
107
|
+
doubleQuote = 34,
|
|
108
|
+
equals = 61,
|
|
109
|
+
exclamation = 33,
|
|
110
|
+
greaterThan = 62,
|
|
111
|
+
hash = 35,
|
|
112
|
+
lessThan = 60,
|
|
113
|
+
minus = 45,
|
|
114
|
+
openBrace = 123,
|
|
115
|
+
openBracket = 91,
|
|
116
|
+
openParen = 40,
|
|
117
|
+
percent = 37,
|
|
118
|
+
plus = 43,
|
|
119
|
+
question = 63,
|
|
120
|
+
semicolon = 59,
|
|
121
|
+
singleQuote = 39,
|
|
122
|
+
slash = 47,
|
|
123
|
+
tilde = 126,
|
|
124
|
+
backspace = 8,
|
|
125
|
+
formFeed = 12,
|
|
126
|
+
byteOrderMark = 65279,
|
|
127
|
+
tab = 9,
|
|
128
|
+
verticalTab = 11
|
|
129
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface FileSystemEntries {
|
|
2
|
+
readonly files: readonly string[];
|
|
3
|
+
readonly directories: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
/** @param path directory of the tsconfig.json */
|
|
6
|
+
export declare function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[];
|
|
7
|
+
export {};
|