Skip to content

Commit

Permalink
fix(cli): updateModuleImports method
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Apr 18, 2022
1 parent 1d1dbb4 commit f4db805
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/generate-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function updateModuleImports(fullDestinationPath: string): void {

const moduleContent = readFileSync(resolvedModulePath).toString();

const shouldUpdateModuleImport = !moduleContent.match(`${componentClassName}`);
const shouldUpdateModuleImport = !moduleContent.match(`${parse(file.name).name}`);
if (!shouldUpdateModuleImport) continue;

const isComponentInSubDirectory =
Expand Down
5 changes: 3 additions & 2 deletions src/cli/tests/commands/generate-component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('GenerateComponent', () => {
it('should generate a module that includes other generated components automatically', () => {
generateComponent(componentName, { middleware: true, service: true, path });
generateComponent(componentName, { module: true, path });
generateComponent(componentName, { repository: true, router: true, path });
generateComponent(componentName, { repository: true, router: true, entity: true, path });

const subDirectory = 'subDirectory';
generateComponent(componentName, { validator: true, path: path + '/' + subDirectory });
Expand All @@ -142,11 +142,12 @@ describe('GenerateComponent', () => {
import { TestValidator } from './${subDirectory}/test.validator';
import { TestRouter } from './test.router';
import { TestRepository } from './test.repository';
import { Test } from './test.entity';
import { TestService } from './test.service';
import { TestMiddleware } from './test.middleware';
@Module({
imports: [TestMiddleware, TestService, TestRepository, TestRouter, TestValidator]
imports: [TestMiddleware, TestService, Test, TestRepository, TestRouter, TestValidator]
})
export class TestModule {}
`)
Expand Down

0 comments on commit f4db805

Please sign in to comment.