Skip to content

Commit 71bf855

Browse files
Meligyfilipesilva
authored andcommitted
fix(generate): revert change to component dir in generate module, as it caused component declaration to go to parent module (#3158)
1 parent 633ece0 commit 71bf855

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/angular-cli/blueprints/module/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ module.exports = {
5858
},
5959

6060
afterInstall: function (options) {
61-
options.entity.name = path.relative(this.dynamicPath.appRoot, this.generatePath);
62-
options.flat = false;
61+
// Note that `this.generatePath` already contains `this.dasherizedModuleName`
62+
// So, the path will end like `name/name`,
63+
// which is correct for `name.component.ts` created in module `name`
64+
var componentPath = path.join(this.generatePath, this.dasherizedModuleName);
65+
options.entity.name = path.relative(this.dynamicPath.appRoot, componentPath);
66+
options.flat = true;
6367
options.route = false;
6468
options.inlineTemplate = false;
6569
options.inlineStyle = false;

tests/e2e/tests/generate/module/module-basic.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {join} from 'path';
22
import {ng} from '../../../utils/process';
3-
import {expectFileToExist} from '../../../utils/fs';
3+
import {expectFileToExist, expectFileToMatch} from '../../../utils/fs';
44
import {expectToFail} from '../../../utils/utils';
55

66

@@ -15,6 +15,7 @@ export default function() {
1515
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.spec.ts')))
1616
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.html')))
1717
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.css')))
18+
.then(() => expectFileToMatch(join(moduleDir, 'test-module.module.ts'), 'TestModuleComponent'))
1819

1920
// Try to run the unit tests.
2021
.then(() => ng('test', '--single-run'));

0 commit comments

Comments
 (0)