diff --git a/packages/angular-cli/blueprints/module/index.js b/packages/angular-cli/blueprints/module/index.js index 03022d434651..efe2920c410d 100644 --- a/packages/angular-cli/blueprints/module/index.js +++ b/packages/angular-cli/blueprints/module/index.js @@ -58,8 +58,8 @@ module.exports = { }, afterInstall: function (options) { - options.entity.name = path.join(this.dasherizedModuleName, this.dasherizedModuleName); - options.flat = true; + options.entity.name = path.relative(this.dynamicPath.appRoot, this.generatePath); + options.flat = false; options.route = false; options.inlineTemplate = false; options.inlineStyle = false; diff --git a/tests/acceptance/generate-module.spec.js b/tests/acceptance/generate-module.spec.js index 2be0d23e7ae9..e264d22ca271 100644 --- a/tests/acceptance/generate-module.spec.js +++ b/tests/acceptance/generate-module.spec.js @@ -56,4 +56,14 @@ describe('Acceptance: ng generate module', function () { expect(existsSync(path.join(testPath, 'two-word', 'two-word.module.spec.ts'))).to.equal(false); }); }); + + it('ng generate module parent/child', function () { + return ng(['generate', 'module', 'parent']).then(() => + ng(['generate', 'module', 'parent/child']).then(() => { + expect(existsSync(path.join(testPath, 'parent/child', 'child.module.ts'))).to.equal(true); + expect(existsSync(path.join(testPath, 'parent/child', 'child.module.spec.ts'))).to.equal(false); + expect(existsSync(path.join(testPath, 'parent/child', 'child.component.ts'))).to.equal(true); + }) + ); + }); });