@@ -36,15 +36,31 @@ export function updateToV20(): Rule {
36
36
] ) ;
37
37
}
38
38
39
+ // Whether the given path should be included when renaming theme token names.
40
+ function shouldRenameTokens ( path : string ) {
41
+ if ( path . includes ( 'node_modules' ) || path . includes ( '.angular' ) || path . includes ( '.git' ) ) {
42
+ return false ;
43
+ }
44
+
45
+ return (
46
+ path . endsWith ( '.html' ) ||
47
+ path . endsWith ( '.css' ) ||
48
+ path . endsWith ( '.scss' ) ||
49
+ path . endsWith ( '.ts' )
50
+ ) ;
51
+ }
52
+
39
53
// Renames any CSS variables beginning with "--mdc-" to be "--mat-". These CSS variables
40
54
// refer to tokens that used to be derived from a mix of MDC and Angular. Now all the tokens
41
55
// are converged on being prefixed "--mat-".
42
56
function renameMdcTokens ( ) : Rule {
43
57
return tree => {
44
58
tree . visit ( path => {
45
- const content = tree . readText ( path ) ;
46
- const updatedContent = content . replace ( '--mdc-' , '--mat-' ) ;
47
- tree . overwrite ( path , updatedContent ) ;
59
+ if ( shouldRenameTokens ( path ) ) {
60
+ const content = tree . readText ( path ) ;
61
+ const updatedContent = content . replace ( '--mdc-' , '--mat-' ) ;
62
+ tree . overwrite ( path , updatedContent ) ;
63
+ }
48
64
} ) ;
49
65
} ;
50
66
}
@@ -78,13 +94,15 @@ function renameComponentTokens(): Rule {
78
94
] ;
79
95
return tree => {
80
96
tree . visit ( path => {
81
- const content = tree . readText ( path ) ;
82
- let updatedContent = content ;
83
- for ( const tokenPrefix of tokenPrefixes ) {
84
- updatedContent = updatedContent . replace ( tokenPrefix . old , tokenPrefix . replacement ) ;
85
- }
86
- if ( content !== updatedContent ) {
87
- tree . overwrite ( path , updatedContent ) ;
97
+ if ( shouldRenameTokens ( path ) ) {
98
+ const content = tree . readText ( path ) ;
99
+ let updatedContent = content ;
100
+ for ( const tokenPrefix of tokenPrefixes ) {
101
+ updatedContent = updatedContent . replace ( tokenPrefix . old , tokenPrefix . replacement ) ;
102
+ }
103
+ if ( content !== updatedContent ) {
104
+ tree . overwrite ( path , updatedContent ) ;
105
+ }
88
106
}
89
107
} ) ;
90
108
} ;
0 commit comments