MCPcopy Create free account
hub / github.com/nodejs/node / getWildcardDirectoryFromSpec

Function getWildcardDirectoryFromSpec

test/fixtures/snapshot/typescript.js:42191–42215  ·  view source on GitHub ↗
(spec, useCaseSensitiveFileNames)

Source from the content-addressed store, hash-verified

42189 return wildcardDirectories;
42190 }
42191 function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
42192 var match = wildcardDirectoryPattern.exec(spec);
42193 if (match) {
42194 // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is
42195 // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use,
42196 // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard
42197 // characters could match any of the central patterns, resulting in bad backtracking.
42198 var questionWildcardIndex = spec.indexOf("?");
42199 var starWildcardIndex = spec.indexOf("*");
42200 var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator);
42201 return {
42202 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
42203 flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex)
42204 || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex)
42205 ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */
42206 };
42207 }
42208 if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42209 return {
42210 key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42211 flags: 1 /* WatchDirectoryFlags.Recursive */
42212 };
42213 }
42214 return undefined;
42215 }
42216 /**
42217 * Determines whether a literal or wildcard file has already been included that has a higher
42218 * extension priority.

Callers 1

getWildcardDirectoriesFunction · 0.85

Calls 2

execMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected