Skip to content

Commit 83ca9c6

Browse files
committed
fix: migration migrates all the times
1 parent f38affc commit 83ca9c6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libs/plugin/src/migrations/migrate-to-ngxtension/migrate-to-ngxtension.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ export default function update(host: Tree) {
1717
}
1818

1919
function migrateApi(host: Tree, path: string, apiName: string, apiImport: string, alias?: string) {
20+
let transformDidRun = false;
2021
const content = host.read(path, 'utf8');
2122
let updatedContent = tsquery.replace(
2223
content,
2324
`ImportDeclaration:has(StringLiteral[value="angular-three"]):has(Identifier[name="${apiName}"])`,
24-
(node: ImportDeclaration) => node.getText().replace(`${apiName},`, '').replace(apiName, ''),
25+
(node: ImportDeclaration) => {
26+
transformDidRun = true;
27+
return node.getText().replace(`${apiName},`, '').replace(apiName, '');
28+
},
2529
);
2630

27-
if (content === updatedContent) {
28-
// NOTE: transformer did not run
29-
return;
31+
if (!transformDidRun) {
32+
return transformDidRun;
3033
}
3134

3235
if (
@@ -49,4 +52,5 @@ ${sf.getFullText()}`;
4952
});
5053

5154
host.write(path, updatedContent);
55+
return transformDidRun;
5256
}

0 commit comments

Comments
 (0)