MCPcopy Index your code
hub / github.com/nodejs/node / getBasePaths

Function getBasePaths

test/fixtures/snapshot/typescript.js:20713–20742  ·  view source on GitHub ↗

* Computes the unique non-wildcard base paths amongst the provided include patterns.

(path, includes, useCaseSensitiveFileNames)

Source from the content-addressed store, hash-verified

20711 * Computes the unique non-wildcard base paths amongst the provided include patterns.
20712 */
20713 function getBasePaths(path, includes, useCaseSensitiveFileNames) {
20714 // Storage for our results in the form of literal paths (e.g. the paths as written by the user).
20715 var basePaths = [path];
20716 if (includes) {
20717 // Storage for literal base paths amongst the include patterns.
20718 var includeBasePaths = [];
20719 for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
20720 var include = includes_1[_i];
20721 // We also need to check the relative paths by converting them to absolute and normalizing
20722 // in case they escape the base path (e.g "..\somedirectory")
20723 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
20724 // Append the literal and canonical candidate base paths.
20725 includeBasePaths.push(getIncludeBasePath(absolute));
20726 }
20727 // Sort the offsets array using either the literal or canonical path representations.
20728 includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
20729 var _loop_2 = function (includeBasePath) {
20730 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
20731 basePaths.push(includeBasePath);
20732 }
20733 };
20734 // Iterate over each include base path and include unique base paths that are not a
20735 // subpath of an existing base path
20736 for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
20737 var includeBasePath = includeBasePaths_1[_a];
20738 _loop_2(includeBasePath);
20739 }
20740 }
20741 return basePaths;
20742 }
20743 function getIncludeBasePath(absolute) {
20744 var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
20745 if (wildcardOffset < 0) {

Callers 1

getFileMatcherPatternsFunction · 0.85

Calls 4

getIncludeBasePathFunction · 0.85
_loop_2Function · 0.85
sortMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected