diff --git a/package.json b/package.json index d76964ba35ce..d9cf4d873e74 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "node ./scripts/publish/build.js", "build:patch": "node ./scripts/patch.js", "build:packages": "for PKG in packages/*; do echo Building $PKG...; tsc -p $PKG; done", - "test": "npm run test:packages && npm run test:cli", + "test": "npm-run-all -c test:packages test:cli", "e2e": "npm run test:e2e", "e2e:nightly": "node tests/e2e_runner.js --nightly", "mobile_test": "mocha tests/e2e/e2e_workflow.spec.js", diff --git a/packages/ast-tools/src/ast-utils.ts b/packages/ast-tools/src/ast-utils.ts index 41fd8664c764..8d0980102116 100644 --- a/packages/ast-tools/src/ast-utils.ts +++ b/packages/ast-tools/src/ast-utils.ts @@ -222,8 +222,8 @@ function _addSymbolToNgModuleMetadata(ngModulePath: string, metadataField: strin position = node.getEnd(); // Get the indentation of the last element, if any. const text = node.getFullText(source); - if (text.startsWith('\n')) { - toInsert = `,${text.match(/^\n(\r?)\s+/)[0]}${metadataField}: [${symbolName}]`; + if (text.match('^\r?\r?\n')) { + toInsert = `,${text.match(/^\r?\n\s+/)[0]}${metadataField}: [${symbolName}]`; } else { toInsert = `, ${metadataField}: [${symbolName}]`; } @@ -235,8 +235,8 @@ function _addSymbolToNgModuleMetadata(ngModulePath: string, metadataField: strin } else { // Get the indentation of the last element, if any. const text = node.getFullText(source); - if (text.startsWith('\n')) { - toInsert = `,${text.match(/^\n(\r?)\s+/)[0]}${symbolName}`; + if (text.match(/^\r?\n/)) { + toInsert = `,${text.match(/^\r?\n(\r?)\s+/)[0]}${symbolName}`; } else { toInsert = `, ${symbolName}`; } diff --git a/packages/ast-tools/src/route-utils.spec.ts b/packages/ast-tools/src/route-utils.spec.ts index fb221f20013c..f1af932454e6 100644 --- a/packages/ast-tools/src/route-utils.spec.ts +++ b/packages/ast-tools/src/route-utils.spec.ts @@ -293,7 +293,7 @@ export default [\n { path: 'new-route', component: NewRouteComponent }\n];`); `\nexport default [\n` + ` { path: 'home', component: HomeComponent,\n` + ` children: [\n` + - ` { path: 'about/:id', component: AboutComponent } ` + + ` { path: 'about/:id', component: AboutComponent }` + `\n ]\n }\n];`); }); }); diff --git a/packages/ast-tools/src/route-utils.ts b/packages/ast-tools/src/route-utils.ts index db40e0a41766..3fd166b0edf8 100644 --- a/packages/ast-tools/src/route-utils.ts +++ b/packages/ast-tools/src/route-utils.ts @@ -416,11 +416,11 @@ function addChildPath (parentObject: ts.Node, pathOptions: any, route: string) { if (childrenNode.length !== 0) { // add to beginning of children array pos = childrenNode[0].getChildAt(2).getChildAt(1).pos; // open bracket - newContent = `\n${spaces}${content}, `; + newContent = `\n${spaces}${content},`; } else { // no children array, add one pos = parentObject.getChildAt(2).pos; // close brace - newContent = `,\n${spaces.substring(2)}children: [\n${spaces}${content} ` + + newContent = `,\n${spaces.substring(2)}children: [\n${spaces}${content}` + `\n${spaces.substring(2)}]\n${spaces.substring(5)}`; } return {newContent: newContent, pos: pos}; diff --git a/scripts/run-packages-spec.js b/scripts/run-packages-spec.js index 33b924b6ea81..987b3ea3d87e 100644 --- a/scripts/run-packages-spec.js +++ b/scripts/run-packages-spec.js @@ -14,6 +14,8 @@ const projectBaseDir = path.join(__dirname, '../packages'); const jasmine = new Jasmine({ projectBaseDir: projectBaseDir }); jasmine.loadConfig({}); jasmine.addReporter(new JasmineSpecReporter()); +// Manually set exit code (needed with custom reporters) +jasmine.onComplete((success) => process.exitCode = !success); // Run the tests. const allTests = diff --git a/tests/acceptance/generate-class.spec.js b/tests/acceptance/generate-class.spec.js index 9215bd32cfc9..d0c38f964135 100644 --- a/tests/acceptance/generate-class.spec.js +++ b/tests/acceptance/generate-class.spec.js @@ -17,6 +17,7 @@ describe('Acceptance: ng generate class', function () { after(conf.restore); beforeEach(function () { + this.timeout(10000); return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); }).then(function () { @@ -25,8 +26,6 @@ describe('Acceptance: ng generate class', function () { }); afterEach(function () { - this.timeout(10000); - return tmp.teardown('./tmp'); }); diff --git a/tests/acceptance/generate-component.spec.js b/tests/acceptance/generate-component.spec.js index c5abd319faf7..6416ef2fff76 100644 --- a/tests/acceptance/generate-component.spec.js +++ b/tests/acceptance/generate-component.spec.js @@ -43,7 +43,7 @@ describe('Acceptance: ng generate component', function () { .then(content => { // Expect that the app.module contains a reference to my-comp and its import. expect(content).matches(/import.*MyCompComponent.*from '.\/my-comp\/my-comp.component';/); - expect(content).matches(/declarations:\s*\[[^\]]+?,\n\s+MyCompComponent\n/m); + expect(content).matches(/declarations:\s*\[[^\]]+?,\r?\n\s+MyCompComponent\r?\n/m); }); }); diff --git a/tests/acceptance/generate-directive.spec.js b/tests/acceptance/generate-directive.spec.js index 93398ee218ea..3620720b2018 100644 --- a/tests/acceptance/generate-directive.spec.js +++ b/tests/acceptance/generate-directive.spec.js @@ -51,7 +51,7 @@ describe('Acceptance: ng generate directive', function () { .then(() => readFile(appModulePath, 'utf-8')) .then(content => { expect(content).matches(/import.*\bMyDirDirective\b.*from '.\/my-dir\/my-dir.directive';/); - expect(content).matches(/declarations:\s*\[[^\]]+?,\n\s+MyDirDirective\n/m); + expect(content).matches(/declarations:\s*\[[^\]]+?,\r?\n\s+MyDirDirective\r?\n/m); }); }); diff --git a/tests/acceptance/generate-pipe.spec.js b/tests/acceptance/generate-pipe.spec.js index c6463697e2b0..2d98f8605895 100644 --- a/tests/acceptance/generate-pipe.spec.js +++ b/tests/acceptance/generate-pipe.spec.js @@ -44,7 +44,7 @@ describe('Acceptance: ng generate pipe', function () { .then(() => readFile(appModulePath, 'utf-8')) .then(content => { expect(content).matches(/import.*\bMyPipePipe\b.*from '.\/my-pipe.pipe';/); - expect(content).matches(/declarations:\s*\[[^\]]+?,\n\s+MyPipePipe\n/m); + expect(content).matches(/declarations:\s*\[[^\]]+?,\r?\n\s+MyPipePipe\r?\n/m); }); });