ts-to-zod icon indicating copy to clipboard operation
ts-to-zod copied to clipboard

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

Open sp88011 opened this issue 1 year ago • 2 comments

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.

sp88011 avatar Jul 31 '23 20:07 sp88011

Feel free to create a PR!

schiller-manuel avatar Feb 06 '24 21:02 schiller-manuel

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?

tvillaren avatar Aug 26 '24 21:08 tvillaren