Skip to content

Commit

Permalink
fix(@schematics/angular): Use branchAndMerge for ng-new
Browse files Browse the repository at this point in the history
  • Loading branch information
Brocco authored and hansl committed Jun 6, 2018
1 parent df83210 commit 700a6bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/schematics/angular/ng-new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import {
SchematicContext,
SchematicsException,
Tree,
apply,
branchAndMerge,
chain,
empty,
mergeWith,
move,
schematic,
} from '@angular-devkit/schematics';
Expand Down Expand Up @@ -55,14 +53,14 @@ export default function (options: NgNewOptions): Rule {
};

return chain([
mergeWith(
apply(empty(), [
branchAndMerge(
chain([
schematic('workspace', workspaceOptions),
schematic('application', applicationOptions),
move(options.directory || options.name),
]),
),
(host: Tree, context: SchematicContext) => {
(_host: Tree, context: SchematicContext) => {
let packageTask;
if (!options.skipInstall) {
packageTask = context.addTask(new NodePackageInstallTask(options.directory));
Expand Down
11 changes: 11 additions & 0 deletions packages/schematics/angular/ng-new/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,15 @@ describe('Ng New Schematic', () => {
const content = tree.readContent('/bar/angular.json');
expect(content).toMatch(/"prefix": "pre"/);
});

it('should set up the app module', () => {
const options: NgNewOptions = {
name: 'foo',
version: '6.0.0',
};

const tree = schematicRunner.runSchematic('ng-new', options);
const moduleContent = tree.readContent('/foo/src/app/app.module.ts');
expect(moduleContent).toMatch(/declarations:\s*\[\s*AppComponent\s*\]/m);
});
});

0 comments on commit 700a6bf

Please sign in to comment.