From e1a1243c33817457927faf719b781db4c9b9c9f9 Mon Sep 17 00:00:00 2001 From: EndyKaufman Date: Sun, 12 May 2019 12:30:19 +0500 Subject: [PATCH] fix: Remove duplicated names (#11) --- src/schematics/rucken-entity-nestjs/index.ts | 10 +++++++++- src/schematics/rucken-entity/index.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/schematics/rucken-entity-nestjs/index.ts b/src/schematics/rucken-entity-nestjs/index.ts index d1601b7..2fd2f31 100644 --- a/src/schematics/rucken-entity-nestjs/index.ts +++ b/src/schematics/rucken-entity-nestjs/index.ts @@ -126,7 +126,7 @@ function createProviders(options: NormalizedSchema, typeName: string, asProvider ); project.addExistingSourceFiles(srcPath); - const allImports = []; + let allImports = []; let allClasses = []; project @@ -152,6 +152,14 @@ function createProviders(options: NormalizedSchema, typeName: string, asProvider )} } from './${sourceFile.getBaseName().replace('.ts', '')}';` ); }); + + allImports = allImports.filter((elem, index, self) => { + return index === self.indexOf(elem); + }); + allClasses = allClasses.filter((elem, index, self) => { + return index === self.indexOf(elem); + }); + const newSourceFile = project.createSourceFile( 'index.ts', ( diff --git a/src/schematics/rucken-entity/index.ts b/src/schematics/rucken-entity/index.ts index 2edf093..dcd1a57 100644 --- a/src/schematics/rucken-entity/index.ts +++ b/src/schematics/rucken-entity/index.ts @@ -91,7 +91,7 @@ function createProviders(options: NormalizedSchema): Rule { ); project.addExistingSourceFiles(srcPath); - const allImports = []; + let allImports = []; let allProviders = []; project @@ -129,6 +129,14 @@ function createProviders(options: NormalizedSchema): Rule { )} } from './${sourceFile.getBaseName().replace('.ts', '')}';` ); }); + + allImports = allImports.filter((elem, index, self) => { + return index === self.indexOf(elem); + }); + allProviders = allProviders.filter((elem, index, self) => { + return index === self.indexOf(elem); + }); + const newSourceFile = project.createSourceFile( 'providers.ts', `import { Provider } from '@angular/core';