Skip to content

Commit 4842685

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@schematics/angular): show warning when a TS Config is not found during migrations
Prior to this change an error was shown when a non existing tsconfig was referenced in the angular.json. This causes the update to fail. Closes #24264 (cherry picked from commit 5a123a6)
1 parent eda96de commit 4842685

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

packages/schematics/angular/migrations/update-15/update-typescript-target.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,33 @@ import { getWorkspace } from '../../utility/workspace';
1313
import { Builders } from '../../utility/workspace-models';
1414

1515
export default function (): Rule {
16-
return async (host) => {
16+
return async (host, context) => {
1717
// Workspace level tsconfig
1818
updateTarget(host, 'tsconfig.json');
1919

2020
const workspace = await getWorkspace(host);
2121

2222
// Find all tsconfig which are refereces used by builders
2323
for (const [, project] of workspace.projects) {
24-
for (const [, target] of project.targets) {
24+
for (const [targetName, target] of project.targets) {
2525
// Update all other known CLI builders that use a tsconfig
2626
const tsConfigs = [target.options || {}, ...Object.values(target.configurations || {})]
2727
.filter((opt) => typeof opt?.tsConfig === 'string')
2828
.map((opt) => (opt as { tsConfig: string }).tsConfig);
2929

30-
const uniqueTsConfigs = [...new Set(tsConfigs)];
30+
const uniqueTsConfigs = new Set(tsConfigs);
31+
for (const tsConfig of uniqueTsConfigs) {
32+
if (host.exists(tsConfig)) {
33+
continue;
34+
}
3135

32-
if (uniqueTsConfigs.length < 1) {
36+
uniqueTsConfigs.delete(tsConfig);
37+
context.logger.warn(
38+
`'${tsConfig}' referenced in the '${targetName}' target does not exist.`,
39+
);
40+
}
41+
42+
if (!uniqueTsConfigs.size) {
3343
continue;
3444
}
3545

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy