Skip to content

Commit ee756ec

Browse files
clydincrisbeto
authored andcommitted
refactor(material/schematics): avoid addTypographyClass rule when not needed
The `addTypographyClass` rule is now fully conditional on the `typography` option. This removes the need to execute the rule at all if the option is disabled.
1 parent 2483dd9 commit ee756ec

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/material/schematics/ng-add/setup-project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {chain, Rule, SchematicContext, Tree} from '@angular-devkit/schematics';
9+
import {chain, noop, Rule, SchematicContext, Tree} from '@angular-devkit/schematics';
1010
import {getProjectFromWorkspace, getProjectStyleFile} from '@angular/cdk/schematics';
1111
import {getWorkspace} from '@schematics/angular/utility/workspace';
1212
import {ProjectType} from '@schematics/angular/utility/workspace-models';
@@ -29,7 +29,7 @@ export default function (options: Schema): Rule {
2929
addThemeToAppStyles(options),
3030
addFontsToIndex(options),
3131
addMaterialAppStyles(options),
32-
addTypographyClass(options),
32+
options.typography ? addTypographyClass(options) : noop(),
3333
]);
3434
}
3535
context.logger.warn(

src/material/schematics/ng-add/theming/theming.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ export function addTypographyClass(options: Schema): Rule {
5757
throw new SchematicsException('No project index HTML file could be found.');
5858
}
5959

60-
if (options.typography) {
61-
projectIndexFiles.forEach(path => addBodyClass(host, path, 'mat-typography'));
62-
}
60+
projectIndexFiles.forEach(path => addBodyClass(host, path, 'mat-typography'));
6361
};
6462
}
6563

0 commit comments

Comments
 (0)