Skip to content

Commit 55ff548

Browse files
committed
fix(component): prevent the command from hanging if no module is found
resolves part of #126
1 parent db9ada9 commit 55ff548

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/generate/component/find-module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function findModule(tree: Tree, options: ComponentOptions, path: string,
1818
}
1919

2020
function findExplicitModule(tree: Tree, path: string, extension: string, moduleName: string) {
21-
while (path) {
21+
while (path && path !== '/') {
2222
const modulePath = normalize(`/${path}/${moduleName}`);
2323
const moduleBaseName = normalize(modulePath).split('/').pop();
2424

@@ -44,7 +44,7 @@ function findImplicitModule(tree: Tree, path: string, extension: string) {
4444
const moduleRe = new RegExp(`.module${extension}.ts`);
4545
const routingModuleRe = new RegExp(`-routing.module${extension}.ts`);
4646

47-
while (dir) {
47+
while (dir && dir.path && dir.path !== '/') {
4848
const matches = dir.subfiles.filter(p => moduleRe.test(p) && !routingModuleRe.test(p));
4949
if (matches.length == 1) {
5050
return join(dir.path, matches[0]);

0 commit comments

Comments
 (0)