Skip to content

Commit

Permalink
feat(@schematics/angular): Add the option to create an empty workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Brocco committed Sep 10, 2018
1 parent 432fe97 commit 444aca3
Show file tree
Hide file tree
Showing 4 changed files with 32 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.empty ? noop : schematic('application', applicationOptions),
move(options.directory || options.name),
]),
),
Expand Down
20 changes: 20 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,24 @@ describe('Ng New Schematic', () => {
const moduleContent = tree.readContent('/foo/src/app/app.module.ts');
expect(moduleContent).toMatch(/declarations:\s*\[\s*AppComponent\s*\]/m);
});

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

const tree = schematicRunner.runSchematic('ng-new', options);
const files = tree.files;
expect(files.indexOf('/bar/angular.json')).toBeGreaterThanOrEqual(0);
});

it('should not create a project', () => {
const options = { ...defaultOptions, empty: true };

const tree = schematicRunner.runSchematic('ng-new', options);
const files = tree.files;
expect(files.indexOf('/bar/src')).toBe(-1);
});


});
});
4 changes: 4 additions & 0 deletions packages/schematics/angular/ng-new/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ export interface Schema {
* Skip creating spec files.
*/
skipTests?: boolean;
/**
* Create an empty workspace with no projects.
*/
empty?: boolean;
}
6 changes: 6 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,12 @@
"type": "boolean",
"default": false,
"alias": "S"
},
"empty": {
"description": "Create an empty workspace with no projects.",
"type": "boolean",
"default": false,
"alias": "e"
}
},
"required": [
Expand Down

0 comments on commit 444aca3

Please sign in to comment.