fabien0102 / ts-to-zod

Generate zod schemas from typescript types/interfaces
MIT License
1.17k stars 65 forks source link

Append created types to specified file, if that file already exists. #150

Open sp88011 opened 1 year ago

sp88011 commented 1 year ago

Feature description

Allow types to be added to existing file, rather than overwriting a file that may exist.

Input

npm ts-to-zod src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts

Output

if src/nowIcanValidateEverything.ts exists, add output to end of file. Otherwise create file.

schiller-manuel commented 7 months ago

Feel free to create a PR!

tvillaren commented 3 weeks ago

Hello @sp88011,

When you write:

if src/nowIcanValidateEverything.ts exists, add output to end of file. Otherwise create file.

👉 what would be the behaviour is we call npm ts-to-zod src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts several times in a row (because iDontTrustThisApi.ts has been modified)?
Appending the generation output of nowIcanValidateEverything.ts which already contains a previous version of the generated Zod validators would lead to a messy file, wouldn't it?

Could you share a bit more about your use case?