Skip to content

Commit e21ed05

Browse files
committed
fix(@angular/cli): fix component not finding closest module
fixes angular#5127
1 parent 86d60bb commit e21ed05

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/@angular/cli/blueprints/component/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ export default Blueprint.extend({
9595
}
9696
} else {
9797
try {
98-
this.pathToModule = findParentModule(
99-
this.project.root, appConfig.root, this.dynamicPath.dir);
98+
this.pathToModule = findParentModule(this.project.root, appConfig.root, this.generatePath);
10099
} catch (e) {
101100
if (!options.skipImport) {
102101
throw `Error locating module for declaration\n\t${e}`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { join } from 'path';
2+
import { ng } from '../../../utils/process';
3+
import { expectFileToMatch } from '../../../utils/fs';
4+
5+
6+
export default function () {
7+
const modulePath = join('src', 'app', 'foo', 'foo.module.ts');
8+
9+
return Promise.resolve()
10+
.then(() => ng('generate', 'module', 'foo'))
11+
.then(() => ng('generate', 'component', 'foo'))
12+
.then(() => expectFileToMatch(modulePath, /import { FooComponent } from '.\/foo.component'/));
13+
}

0 commit comments

Comments
 (0)