(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames)
| 139467 | return combinePathsSafe(ts.getDirectoryPath(a1), rel); |
| 139468 | } |
| 139469 | function updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { |
| 139470 | var configFile = program.getCompilerOptions().configFile; |
| 139471 | if (!configFile) |
| 139472 | return; |
| 139473 | var configDir = ts.getDirectoryPath(configFile.fileName); |
| 139474 | var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile); |
| 139475 | if (!jsonObjectLiteral) |
| 139476 | return; |
| 139477 | forEachProperty(jsonObjectLiteral, function (property, propertyName) { |
| 139478 | switch (propertyName) { |
| 139479 | case "files": |
| 139480 | case "include": |
| 139481 | case "exclude": { |
| 139482 | var foundExactMatch = updatePaths(property); |
| 139483 | if (foundExactMatch || propertyName !== "include" || !ts.isArrayLiteralExpression(property.initializer)) |
| 139484 | return; |
| 139485 | var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); |
| 139486 | if (includes.length === 0) |
| 139487 | return; |
| 139488 | var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); |
| 139489 | // If there isn't some include for this, add a new one. |
| 139490 | if (ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && |
| 139491 | !ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { |
| 139492 | changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.factory.createStringLiteral(relativePath(newFileOrDirPath))); |
| 139493 | } |
| 139494 | return; |
| 139495 | } |
| 139496 | case "compilerOptions": |
| 139497 | forEachProperty(property.initializer, function (property, propertyName) { |
| 139498 | var option = ts.getOptionFromName(propertyName); |
| 139499 | if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { |
| 139500 | updatePaths(property); |
| 139501 | } |
| 139502 | else if (propertyName === "paths") { |
| 139503 | forEachProperty(property.initializer, function (pathsProperty) { |
| 139504 | if (!ts.isArrayLiteralExpression(pathsProperty.initializer)) |
| 139505 | return; |
| 139506 | for (var _i = 0, _a = pathsProperty.initializer.elements; _i < _a.length; _i++) { |
| 139507 | var e = _a[_i]; |
| 139508 | tryUpdateString(e); |
| 139509 | } |
| 139510 | }); |
| 139511 | } |
| 139512 | }); |
| 139513 | return; |
| 139514 | } |
| 139515 | }); |
| 139516 | function updatePaths(property) { |
| 139517 | var elements = ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer]; |
| 139518 | var foundExactMatch = false; |
| 139519 | for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { |
| 139520 | var element = elements_1[_i]; |
| 139521 | foundExactMatch = tryUpdateString(element) || foundExactMatch; |
| 139522 | } |
| 139523 | return foundExactMatch; |
| 139524 | } |
| 139525 | function tryUpdateString(element) { |
| 139526 | if (!ts.isStringLiteral(element)) |
no test coverage detected