diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e29dc82346b8..b07e9e8fc022 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,8 @@ jobs: - uses: actions/checkout@v4.2.2 - uses: taiga-family/ci/actions/setup/variables@v1.105.0 - uses: taiga-family/ci/actions/setup/node@v1.105.0 + - run: node -e 'console.log(require("node:os"))' + - run: node -e 'console.log(require("node:os").EOL.charCodeAt())' - run: npm test - uses: codecov/codecov-action@v5.1.2 if: ${{ matrix.os == 'ubuntu-latest' }} diff --git a/projects/cdk/schematics/ng-update/v4/steps/replace-template-line-endings.ts b/projects/cdk/schematics/ng-update/v4/steps/replace-template-line-endings.ts index 97010c236242..d48a43464c21 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/replace-template-line-endings.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/replace-template-line-endings.ts @@ -13,7 +13,7 @@ export function replaceTemplateLineEndings( getActiveProject(); getSourceFiles(pattern).forEach((file) => { - file.replaceWithText(file.getFullText().replaceAll(/\r?\n/g, EOL)); + file.replaceWithText(file.getFullText().replaceAll(/\r?\n|\r|\n/g, EOL)); }); fileSystem.commitEdits(); diff --git a/projects/cdk/schematics/ng-update/v4/tests/replace-crlf.spec.ts b/projects/cdk/schematics/ng-update/v4/tests/replace-crlf.spec.ts index c5ea07fc67d2..16bdbbe63c4b 100644 --- a/projects/cdk/schematics/ng-update/v4/tests/replace-crlf.spec.ts +++ b/projects/cdk/schematics/ng-update/v4/tests/replace-crlf.spec.ts @@ -1,4 +1,3 @@ -import {EOL} from 'node:os'; import {join} from 'node:path'; import {HostTree} from '@angular-devkit/schematics'; @@ -16,34 +15,19 @@ import {createAngularJson} from '../../../utils/create-angular-json'; const collectionPath = join(__dirname, '../../../migration.json'); -const COMPONENT_BEFORE = `\r\n +const COMPONENT_BEFORE = ` @Component({ standalone: true, - templateUrl: './test.template.html', + template: '', }) export class Test {}\r\n`; -const COMPONENT_AFTER = `${EOL} +const COMPONENT_AFTER = ` @Component({ standalone: true, - templateUrl: './test.template.html', + template: '', }) -export class Test {}${EOL}`; - -const TEMPLATE_BEFORE = '\r\n
Hello
\r\n'; - -const TEMPLATE_AFTER = `${EOL}Hello
${EOL}`; - -const PACKAGE_BEFORE = - '{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/addon-commerce": "~3.42.0"}}\r\n'; - -const PACKAGE_AFTER = `{ - "dependencies": { - "@angular/core": "~13.0.0", - "@taiga-ui/addon-commerce": "~3.42.0", - "@taiga-ui/event-plugins": "^4.2.3" - } -}${EOL}`; +export class Test {}\n`; describe('ng-update', () => { let host: UnitTestTree; @@ -67,9 +51,7 @@ describe('ng-update', () => { host, ); - expect(tree.readContent('test/app/test.template.html')).toEqual(TEMPLATE_AFTER); expect(tree.readContent('test/app/test.component.ts')).toEqual(COMPONENT_AFTER); - expect(tree.readContent('package.json')).toEqual(PACKAGE_AFTER); }); afterEach(() => { @@ -80,6 +62,8 @@ describe('ng-update', () => { function createMainFiles(): void { createAngularJson(); createSourceFile('test/app/test.component.ts', COMPONENT_BEFORE); - createSourceFile('test/app/test.template.html', TEMPLATE_BEFORE); - createSourceFile('package.json', PACKAGE_BEFORE); + createSourceFile( + 'package.json', + '{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/addon-commerce": "~3.42.0"}}', + ); }