Skip to content

Commit 562ce8c

Browse files
committed
feat(exporters): fixed new line at end of comment
1 parent 7a27c48 commit 562ce8c

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,6 @@ export class UpdateChanges {
9898
return this._tsFiles;
9999
}
100100

101-
private _ModuletTsFiles: string[] = [];
102-
public get moduleTsFiles(): string[] {
103-
if (!this._ModuletTsFiles.length) {
104-
this.sourceDirsVisitor((fulPath, entry) => {
105-
if (fulPath.endsWith('.module.ts')) {
106-
this._ModuletTsFiles.push(entry.path);
107-
}
108-
});
109-
}
110-
return this._ModuletTsFiles;
111-
}
112-
113101
private _sassFiles: string[] = [];
114102
/** Sass (both .scss and .sass) files in the project being updated. */
115103
public get sassFiles(): string[] {

projects/igniteui-angular/migrations/update-13_0_0/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ describe(`Update to ${version}`, () => {
202202
});
203203

204204
it('should insert a comment when exporter services are present in module.ts files', async () => {
205-
appTree.create('/testSrc/appPrefix/component/app.module.ts', `
206-
import { NgModule } from "@angular/core";
205+
appTree.create('/testSrc/appPrefix/component/app.module.ts',
206+
`import { NgModule } from "@angular/core";
207207
import { FormsModule } from "@angular/forms";
208208
import { BrowserModule } from "@angular/platform-browser";
209209
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";

projects/igniteui-angular/migrations/update-13_0_0/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
1717
const TAGS = ['igx-grid', 'igx-tree-grid', 'igx-hierarchical-grid'];
1818
const tsFiles = update.tsFiles;
1919
const SERVICES = ['IgxCsvExporterService', 'IgxExcelExporterService'];
20-
const moduleTsFiles = update.moduleTsFiles;
2120

2221
for (const path of update.templateFiles) {
2322
findElementNodes(parseFile(host, path), TAGS)
@@ -64,6 +63,7 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
6463
});
6564
}
6665

66+
const moduleTsFiles = tsFiles.filter(x => x.endsWith('.module.ts'));
6767
for (const path of moduleTsFiles) {
6868
let content = host.read(path)?.toString();
6969
const servicesInFile = [];
@@ -74,7 +74,13 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
7474
});
7575

7676
if (servicesInFile.length > 0) {
77-
const comment = '// ' + servicesInFile.join(' and ') + ' no longer need to be manually provided and can be safely removed.';
77+
let newLine = '\n';
78+
if (content.indexOf('\r\n') > -1) {
79+
newLine = '\r\n';
80+
}
81+
82+
const comment =
83+
'// ' + servicesInFile.join(' and ') + ' no longer need to be manually provided and can be safely removed.' + newLine;
7884
content = comment + content;
7985
host.overwrite(path, content);
8086
}

0 commit comments

Comments
 (0)