Skip to content

Commit e2eafda

Browse files
authored
Merge pull request #9241 from IgniteUI/dpetev/migrations-rename-fixes
Migrations rename fixes
2 parents 8b92c76 + 72b6886 commit e2eafda

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

projects/igniteui-angular/migrations/common/UpdateChanges.spec.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ describe('UpdateChanges', () => {
6565
'test2.component.html',
6666
'<igx-remove attr></igx-remove><igx-component>'
6767
);
68+
appTree.create(
69+
'test3.component.html',
70+
'<igx-remove-me-not attr></igx-remove-me-not> <igx-component> <igx-component-child></igx-component-child> </igx-component>'
71+
);
6872

6973
const update = new UnitUpdateChanges(__dirname, appTree);
7074
expect(fs.existsSync).toHaveBeenCalledWith(jsonPath);
@@ -74,6 +78,9 @@ describe('UpdateChanges', () => {
7478
update.applyChanges();
7579
expect(appTree.readContent('test.component.html')).toEqual('<igx-replaced> <content> </igx-replaced> ');
7680
expect(appTree.readContent('test2.component.html')).toEqual('<igx-replaced>');
81+
expect(appTree.readContent('test3.component.html')).toEqual(
82+
'<igx-remove-me-not attr></igx-remove-me-not> <igx-replaced> <igx-component-child></igx-component-child> </igx-replaced>'
83+
);
7784
done();
7885
});
7986

@@ -175,7 +182,7 @@ describe('UpdateChanges', () => {
175182
});
176183
spyOn<any>(fs, 'readFileSync').and.callFake(() => JSON.stringify(inputJson));
177184

178-
const fileContent = `<one [replaceMe]="a"> <comp\r\ntag [replaceMe]="dwdw" [oldProp]=''> </other> <another oldProp="b" />`;
185+
let fileContent = `<one [replaceMe]="a"> <comp\r\ntag [replaceMe]="dwdw" [oldProp]=''> </other> <another oldProp="b" />`;
179186
appTree.create('test.component.html', fileContent);
180187

181188
const update = new UnitUpdateChanges(__dirname, appTree);
@@ -213,6 +220,15 @@ describe('UpdateChanges', () => {
213220
update4.applyChanges();
214221
expect(appTree.readContent('test.component.html')).toEqual(
215222
`<comp\r\ntag [oldProp]="g" [replaced]="NOT.replaceMe" ><another [otherProp]="oldProp" /></comp>`);
223+
224+
225+
fileContent = `<span [bait]="replaceMe"><ng-container ngProjectAs="comp"> sike! </ng-container></span>`;
226+
appTree.overwrite('test.component.html', fileContent);
227+
update4.applyChanges();
228+
expect(appTree.readContent('test.component.html')).toEqual(
229+
`<span [bait]="replaceMe"><ng-container ngProjectAs="comp"> sike! </ng-container></span>`
230+
);
231+
216232
done();
217233
});
218234

projects/igniteui-angular/migrations/common/UpdateChanges.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class UpdateChanges {
198198
regSource = String.raw`\<${change.selector}[\s\S]*?\<\/${change.selector}\>`;
199199
replace = '';
200200
} else {
201-
regSource = String.raw`\<(\/?)${change.selector}`;
201+
regSource = String.raw`\<(\/?)${change.selector}(?=[\s\>])`;
202202
replace = `<$1${change.replaceWith}`;
203203
}
204204
break;
@@ -276,6 +276,9 @@ export class UpdateChanges {
276276
}
277277

278278
const matches = fileContent.match(new RegExp(searchPattern, 'g'));
279+
if (!matches) {
280+
continue;
281+
}
279282

280283
for (const match of matches) {
281284
let replaceStatement = replace;

0 commit comments

Comments
 (0)