Skip to content

Commit 700a6bf

Browse files
Broccohansl
authored andcommitted
fix(@schematics/angular): Use branchAndMerge for ng-new
1 parent df83210 commit 700a6bf

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/schematics/angular/ng-new/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import {
1010
SchematicContext,
1111
SchematicsException,
1212
Tree,
13-
apply,
13+
branchAndMerge,
1414
chain,
15-
empty,
16-
mergeWith,
1715
move,
1816
schematic,
1917
} from '@angular-devkit/schematics';
@@ -55,14 +53,14 @@ export default function (options: NgNewOptions): Rule {
5553
};
5654

5755
return chain([
58-
mergeWith(
59-
apply(empty(), [
56+
branchAndMerge(
57+
chain([
6058
schematic('workspace', workspaceOptions),
6159
schematic('application', applicationOptions),
6260
move(options.directory || options.name),
6361
]),
6462
),
65-
(host: Tree, context: SchematicContext) => {
63+
(_host: Tree, context: SchematicContext) => {
6664
let packageTask;
6765
if (!options.skipInstall) {
6866
packageTask = context.addTask(new NodePackageInstallTask(options.directory));

packages/schematics/angular/ng-new/index_spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,15 @@ describe('Ng New Schematic', () => {
4646
const content = tree.readContent('/bar/angular.json');
4747
expect(content).toMatch(/"prefix": "pre"/);
4848
});
49+
50+
it('should set up the app module', () => {
51+
const options: NgNewOptions = {
52+
name: 'foo',
53+
version: '6.0.0',
54+
};
55+
56+
const tree = schematicRunner.runSchematic('ng-new', options);
57+
const moduleContent = tree.readContent('/foo/src/app/app.module.ts');
58+
expect(moduleContent).toMatch(/declarations:\s*\[\s*AppComponent\s*\]/m);
59+
});
4960
});

0 commit comments

Comments
 (0)