Skip to content

Commit

Permalink
fix(Schematics): Add handling of flat option to entity blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored and MikeRyanDev committed Jan 11, 2018
1 parent d72084f commit fb8d2c6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/schematics/src/entity/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ describe('Entity Schematic', () => {
expect(tree.files[2]).toEqual('/src/app/foo.reducer.ts');
});

it('should create a folder if flat is false', () => {
const tree = schematicRunner.runSchematic('entity', {
...defaultOptions,
flat: false,
});
expect(tree.files.length).toEqual(3);
expect(tree.files[0]).toEqual('/src/app/foo/foo.actions.ts');
expect(tree.files[1]).toEqual('/src/app/foo/foo.model.ts');
expect(tree.files[2]).toEqual('/src/app/foo/foo.reducer.ts');
});

it('should create 4 files if spec is true', () => {
const options = {
...defaultOptions,
Expand Down
1 change: 1 addition & 0 deletions modules/schematics/src/entity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function(options: EntityOptions): Rule {
options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')),
template({
...stringUtils,
'if-flat': (s: string) => (options.flat ? '' : s),
...(options as object),
dot: () => '.',
}),
Expand Down
1 change: 1 addition & 0 deletions modules/schematics/src/entity/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface Schema {
spec?: boolean;
module?: string;
reducers?: string;
flat?: boolean;
}
5 changes: 5 additions & 0 deletions modules/schematics/src/entity/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
"type": "string",
"description": "Specifies the declaring module.",
"aliases": ["m"]
},
"flat": {
"type": "boolean",
"default": true,
"description": "Flag to indicate if a dir is created."
}
},
"required": [
Expand Down

0 comments on commit fb8d2c6

Please sign in to comment.