From 43cbbfe1b6f691cad547fc266d113389d585ef33 Mon Sep 17 00:00:00 2001 From: "Meligy, GuruStop.NET" Date: Thu, 17 Nov 2016 22:25:42 +1100 Subject: [PATCH] fix(generate): revert change to component dir in generate module, as it caused component declaration to go to parent module (#3158) --- packages/angular-cli/blueprints/module/index.js | 8 ++++++-- tests/e2e/tests/generate/module/module-basic.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/angular-cli/blueprints/module/index.js b/packages/angular-cli/blueprints/module/index.js index 3cd3b5646119..1ee4be43aea8 100644 --- a/packages/angular-cli/blueprints/module/index.js +++ b/packages/angular-cli/blueprints/module/index.js @@ -58,8 +58,12 @@ module.exports = { }, afterInstall: function (options) { - options.entity.name = path.relative(this.dynamicPath.appRoot, this.generatePath); - options.flat = false; + // Note that `this.generatePath` already contains `this.dasherizedModuleName` + // So, the path will end like `name/name`, + // which is correct for `name.component.ts` created in module `name` + var componentPath = path.join(this.generatePath, this.dasherizedModuleName); + options.entity.name = path.relative(this.dynamicPath.appRoot, componentPath); + options.flat = true; options.route = false; options.inlineTemplate = false; options.inlineStyle = false; diff --git a/tests/e2e/tests/generate/module/module-basic.ts b/tests/e2e/tests/generate/module/module-basic.ts index 2ba3dfc06313..071c20f3bea7 100644 --- a/tests/e2e/tests/generate/module/module-basic.ts +++ b/tests/e2e/tests/generate/module/module-basic.ts @@ -1,6 +1,6 @@ import {join} from 'path'; import {ng} from '../../../utils/process'; -import {expectFileToExist} from '../../../utils/fs'; +import {expectFileToExist, expectFileToMatch} from '../../../utils/fs'; import {expectToFail} from '../../../utils/utils'; @@ -15,6 +15,7 @@ export default function() { .then(() => expectFileToExist(join(moduleDir, 'test-module.component.spec.ts'))) .then(() => expectFileToExist(join(moduleDir, 'test-module.component.html'))) .then(() => expectFileToExist(join(moduleDir, 'test-module.component.css'))) + .then(() => expectFileToMatch(join(moduleDir, 'test-module.module.ts'), 'TestModuleComponent')) // Try to run the unit tests. .then(() => ng('test', '--single-run'));