Skip to content

Commit fb8d2c6

Browse files
brandonrobertsMikeRyanDev
authored andcommitted
fix(Schematics): Add handling of flat option to entity blueprint
1 parent d72084f commit fb8d2c6

File tree

8 files changed

+18
-0
lines changed

8 files changed

+18
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

modules/schematics/src/entity/index.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ describe('Entity Schematic', () => {
3131
expect(tree.files[2]).toEqual('/src/app/foo.reducer.ts');
3232
});
3333

34+
it('should create a folder if flat is false', () => {
35+
const tree = schematicRunner.runSchematic('entity', {
36+
...defaultOptions,
37+
flat: false,
38+
});
39+
expect(tree.files.length).toEqual(3);
40+
expect(tree.files[0]).toEqual('/src/app/foo/foo.actions.ts');
41+
expect(tree.files[1]).toEqual('/src/app/foo/foo.model.ts');
42+
expect(tree.files[2]).toEqual('/src/app/foo/foo.reducer.ts');
43+
});
44+
3445
it('should create 4 files if spec is true', () => {
3546
const options = {
3647
...defaultOptions,

modules/schematics/src/entity/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function(options: EntityOptions): Rule {
3838
options.spec ? noop() : filter(path => !path.endsWith('__spec.ts')),
3939
template({
4040
...stringUtils,
41+
'if-flat': (s: string) => (options.flat ? '' : s),
4142
...(options as object),
4243
dot: () => '.',
4344
}),

modules/schematics/src/entity/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export interface Schema {
99
spec?: boolean;
1010
module?: string;
1111
reducers?: string;
12+
flat?: boolean;
1213
}

modules/schematics/src/entity/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"type": "string",
3333
"description": "Specifies the declaring module.",
3434
"aliases": ["m"]
35+
},
36+
"flat": {
37+
"type": "boolean",
38+
"default": true,
39+
"description": "Flag to indicate if a dir is created."
3540
}
3641
},
3742
"required": [

0 commit comments

Comments
 (0)