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

Function getFileNamesFromConfigSpecs

test/fixtures/snapshot/typescript.js:41990–42066  ·  view source on GitHub ↗
(configFileSpecs, basePath, options, host, extraFileExtensions)

Source from the content-addressed store, hash-verified

41988 */
41989 /* @internal */
41990 function getFileNamesFromConfigSpecs(configFileSpecs, basePath, options, host, extraFileExtensions) {
41991 if (extraFileExtensions === void 0) { extraFileExtensions = ts.emptyArray; }
41992 basePath = ts.normalizePath(basePath);
41993 var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
41994 // Literal file names (provided via the "files" array in tsconfig.json) are stored in a
41995 // file map with a possibly case insensitive key. We use this map later when when including
41996 // wildcard paths.
41997 var literalFileMap = new ts.Map();
41998 // Wildcard paths (provided via the "includes" array in tsconfig.json) are stored in a
41999 // file map with a possibly case insensitive key. We use this map to store paths matched
42000 // via wildcard, and to handle extension priority.
42001 var wildcardFileMap = new ts.Map();
42002 // Wildcard paths of json files (provided via the "includes" array in tsconfig.json) are stored in a
42003 // file map with a possibly case insensitive key. We use this map to store paths matched
42004 // via wildcard of *.json kind
42005 var wildCardJsonFileMap = new ts.Map();
42006 var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs;
42007 // Rather than re-query this for each file and filespec, we query the supported extensions
42008 // once and store it on the expansion context.
42009 var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
42010 var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
42011 // Literal files are always included verbatim. An "include" or "exclude" specification cannot
42012 // remove a literal file.
42013 if (validatedFilesSpec) {
42014 for (var _i = 0, validatedFilesSpec_1 = validatedFilesSpec; _i < validatedFilesSpec_1.length; _i++) {
42015 var fileName = validatedFilesSpec_1[_i];
42016 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
42017 literalFileMap.set(keyMapper(file), file);
42018 }
42019 }
42020 var jsonOnlyIncludeRegexes;
42021 if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
42022 var _loop_6 = function (file) {
42023 if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) {
42024 // Valid only if *.json specified
42025 if (!jsonOnlyIncludeRegexes) {
42026 var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); });
42027 var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); });
42028 jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
42029 }
42030 var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
42031 if (includeIndex !== -1) {
42032 var key_1 = keyMapper(file);
42033 if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
42034 wildCardJsonFileMap.set(key_1, file);
42035 }
42036 }
42037 return "continue";
42038 }
42039 // If we have already included a literal or wildcard path with a
42040 // higher priority extension, we should skip this file.
42041 //
42042 // This handles cases where we may encounter both <file>.ts and
42043 // <file>.d.ts (or <file>.js if "allowJs" is enabled) in the same
42044 // directory when they are compilation outputs.
42045 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
42046 return "continue";
42047 }

Callers 1

getFileNamesFunction · 0.85

Calls 4

_loop_6Function · 0.85
concatMethod · 0.80
setMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected