Skip to content

Commit 355a8e6

Browse files
wKozaalexeagle
authored andcommitted
fix(@schematics/angular): respect the flag when we create a guard with schematics
1 parent 32e3b7c commit 355a8e6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/schematics/angular/guard/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default function (options: GuardOptions): Rule {
6565
...strings,
6666
...options,
6767
}),
68-
move(parsedPath.path),
68+
move(parsedPath.path + (options.flat ? '' : '/' + strings.dasherize(options.name))),
6969
]);
7070

7171
return chain([

packages/schematics/angular/guard/index_spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ describe('Guard Schematic', () => {
5656
expect(files).toContain('/projects/bar/src/app/foo.guard.ts');
5757
});
5858

59+
it('should respect the flat flag', () => {
60+
const options = { ...defaultOptions, flat: false };
61+
62+
const tree = schematicRunner.runSchematic('guard', options, appTree);
63+
const files = tree.files;
64+
expect(files).toContain('/projects/bar/src/app/foo/foo.guard.spec.ts');
65+
expect(files).toContain('/projects/bar/src/app/foo/foo.guard.ts');
66+
});
67+
5968
it('should respect the sourceRoot value', () => {
6069
const config = JSON.parse(appTree.readContent('/angular.json'));
6170
config.projects.bar.sourceRoot = 'projects/bar/custom';

0 commit comments

Comments
 (0)