Skip to content

Commit b91fffe

Browse files
committed
fix(generate): fix module component path if module is created in child folder
fixes #3063
1 parent f815228 commit b91fffe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ module.exports = {
5858
},
5959

6060
afterInstall: function (options) {
61-
options.entity.name = path.join(this.dasherizedModuleName, this.dasherizedModuleName);
61+
var componentPath = path.join(this.generatePath, this.dasherizedModuleName);
62+
63+
options.entity.name = path.relative(this.dynamicPath.appRoot, componentPath);
6264
options.flat = true;
6365
options.route = false;
6466
options.inlineTemplate = false;

tests/acceptance/generate-module.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,14 @@ describe('Acceptance: ng generate module', function () {
5656
expect(existsSync(path.join(testPath, 'two-word', 'two-word.module.spec.ts'))).to.equal(false);
5757
});
5858
});
59+
60+
it('ng generate module parent/child', function () {
61+
return ng(['generate', 'module', 'parent']).then(() =>
62+
ng(['generate', 'module', 'parent/child']).then(() => {
63+
expect(existsSync(path.join(testPath, 'parent/child', 'child.module.ts'))).to.equal(true);
64+
expect(existsSync(path.join(testPath, 'parent/child', 'child.module.spec.ts'))).to.equal(false);
65+
expect(existsSync(path.join(testPath, 'parent/child', 'child.component.ts'))).to.equal(true);
66+
})
67+
);
68+
});
5969
});

0 commit comments

Comments
 (0)