mrjono1 / joi-to-typescript

Convert Joi Schemas to TypeScript interfaces
MIT License
126 stars 40 forks source link

Files in subfolders named the same fail to generate #295

Closed bliakher closed 1 year ago

bliakher commented 1 year ago

I'm incorporating this library into my existing project and I ran into the following issue:

Inside my folder with Joi schemas I have 2 subdirectories with files that are named the same:

/schema
    /admin
       - profiles.ts
    /user
       - profiles.ts

I generate interfaces with a call to:

convertFromDirectory(
  schemaDirectory: './.../schema',
  typeOutputDirectory: './.../interfaces',
  schemaFileSuffix: '',
  debug: true,
)

When I checked the output /interfaces directory, /interfaces/admin/profiles.ts file exists but /interfaces/user/profiles.ts is not generated.

Debug console output has profiles.ts - Processing for both files and the generated index.ts file in /interfaces/user has export for ./profiles. But the generated file itself is not created

I tested and this issue seems to happen for any pair of files with the same name in different subdirectories.

Issue is solvable by renaming files to have different names.

mrjono1 commented 1 year ago

Hi I should create some more helpers for this, I recommend that you run convertFromDirectory on /schema/admin and /schema/user directories, this will allow for the two files with the same name

mrjono1 commented 1 year ago

no activity closing