Skip to content

Commit 74c2a08

Browse files
committedOct 31, 2024·
fix(google-maps): resolve CLI errors in ng update schematic (#29947)
* Fixes that the schematic was throwing an error for non-UTF8 files, because we were using `Tree.readText` instead of `Tree.read.toString`. * Fixes that we appear to be traversing the `node_modules`. Fixes #29917. (cherry picked from commit f890455)
1 parent 1975f3f commit 74c2a08

File tree

1 file changed

+11
-6
lines changed
  • src/google-maps/schematics/ng-update

1 file changed

+11
-6
lines changed
 

‎src/google-maps/schematics/ng-update/index.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ const DEPRECATED_CLASS_NAME = 'DeprecatedMapMarkerClusterer';
2626
export function updateToV19(): Rule {
2727
return tree => {
2828
tree.visit(path => {
29+
if (path.includes('node_modules')) {
30+
return;
31+
}
32+
2933
if (path.endsWith('.html')) {
30-
const content = tree.readText(path);
34+
const content = tree.read(path)?.toString();
3135

32-
if (content.includes('<' + TAG_NAME)) {
36+
if (content && content.includes('<' + TAG_NAME)) {
3337
tree.overwrite(path, migrateHtml(content));
3438
}
3539
} else if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
@@ -48,13 +52,14 @@ function migrateHtml(content: string): string {
4852

4953
/** Migrates a TypeScript file from the old tag and class names to the new ones. */
5054
function migrateTypeScript(path: Path, tree: Tree) {
51-
const content = tree.readText(path);
55+
const content = tree.read(path)?.toString();
5256

5357
// Exit early if none of the symbols we're looking for are mentioned.
5458
if (
55-
!content.includes('<' + TAG_NAME) &&
56-
!content.includes(MODULE_NAME) &&
57-
!content.includes(CLASS_NAME)
59+
!content ||
60+
(!content.includes('<' + TAG_NAME) &&
61+
!content.includes(MODULE_NAME) &&
62+
!content.includes(CLASS_NAME))
5863
) {
5964
return;
6065
}

0 commit comments

Comments
 (0)
Please sign in to comment.