Skip to content

Commit

Permalink
feat(@schematics/angular): Add the option to allow preventing the cre…
Browse files Browse the repository at this point in the history
…ation of an application

Fixes #12216
  • Loading branch information
Brocco authored and alexeagle committed Sep 26, 2018
1 parent 5c6c704 commit b16cb27
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/schematics/angular/ng-new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
empty,
mergeWith,
move,
noop,
schematic,
} from '@angular-devkit/schematics';
import {
Expand Down Expand Up @@ -60,7 +61,7 @@ export default function (options: NgNewOptions): Rule {
mergeWith(
apply(empty(), [
schematic('workspace', workspaceOptions),
schematic('application', applicationOptions),
options.createApplication ? schematic('application', applicationOptions) : noop,
move(options.directory || options.name),
]),
),
Expand Down
9 changes: 9 additions & 0 deletions packages/schematics/angular/ng-new/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ describe('Ng New Schematic', () => {
const moduleContent = tree.readContent('/foo/src/app/app.module.ts');
expect(moduleContent).toMatch(/declarations:\s*\[\s*AppComponent\s*\]/m);
});

it('createApplication=false should create an empty workspace', () => {
const options = { ...defaultOptions, createApplication: false };

const tree = schematicRunner.runSchematic('ng-new', options);
const files = tree.files;
expect(files.indexOf('/bar/angular.json')).toBeGreaterThanOrEqual(0);
expect(files.indexOf('/bar/src')).toBe(-1);
});
});
5 changes: 5 additions & 0 deletions packages/schematics/angular/ng-new/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
"type": "boolean",
"default": false,
"alias": "S"
},
"createApplication": {
"description": "Flag to toggle creation of an application in the new workspace.",
"type": "boolean",
"default": true
}
},
"required": [
Expand Down

0 comments on commit b16cb27

Please sign in to comment.