Skip to content

Commit

Permalink
fix(@schrematics/angular): show warning when a TS Config is not found…
Browse files Browse the repository at this point in the history
… 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 angular#24264
  • Loading branch information
alan-agius4 committed Nov 17, 2022
1 parent bf82d5d commit 5104089
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@ import { getWorkspace } from '../../utility/workspace';
import { Builders } from '../../utility/workspace-models';

export default function (): Rule {
return async (host) => {
return async (host, context) => {
// Workspace level tsconfig
updateTarget(host, 'tsconfig.json');

const workspace = await getWorkspace(host);

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

const uniqueTsConfigs = [...new Set(tsConfigs)];
const uniqueTsConfigs = new Set(tsConfigs);
for (const tsConfig of uniqueTsConfigs) {
if (host.exists(tsConfig)) {
continue;
}

if (uniqueTsConfigs.length < 1) {
uniqueTsConfigs.delete(tsConfig);
context.logger.warn(
`'${tsConfig}' referenced in the '${targetName}' target does not exist.`,
);
}

if (!uniqueTsConfigs.size) {
continue;
}

Expand Down

0 comments on commit 5104089

Please sign in to comment.