Angular schematics append barrel file

261 views Asked by At

I am creating some angular schematics for my project to create all required services/components with all imports etc. The problem is that I use index file to import all services etc and my structure might look like this:

| src
|
|-- app
    |
    |-- module
           |
           |-- components
           |      |
           |      |-- index.ts
           |      |-- component1
           |      |     |
           |      |     |-- component1.component.ts
           |      |
           |      |-- component2
           |      |     |
           |      |     |-- component2.component.ts
           |
           |
           |-- services
                  |
                  |-- index.ts
                  |-- service1
                  |-- service2

Right now when I create 1st component in module it works great, but when I create 2nd I get an error telling me that file index.ts exists. I have tried different merge strategies but neither appends the file and I always get same issue.

Right now I keep all my index.ts files together with other templates. Is there any good practice/way to do it or do I need to manually find if file exists and if so open it and edit? Or is there a 'fast way'?

0

There are 0 answers