Closed SebastianKuehn closed 3 years ago
@SebastianKuehn hm... perhaps we should provide the overwrite option? Or at least allow it to be opt-in with a command line argument?
Either that or be smart and expand the list of supplies scripts to include any relative guard files. But I feel like ultimately that's the same thing.
I think we should also catch that error from ts-morph and report it a bit more gracefully.
Would you be interested in opening a PR with the relevant changes? Happy to answer any questions if you get stuck.
Hey, I just noticed your error:
A source file already exists at the provided file path: /fullpath/to/src/Person.ts
This is not a guard file! Shouldn't it be Person.type-guard.ts
with those arguments?
@rhys-vdw Hi, sorry thats a typo from my side. The error contains a guard-file. I tried to be brief and messed up the file-part of the error message.
Thought that might be the case, all g. My original reply stands. 👍
Calling
ts-auto-guard --guard-file-name=type-guard src/Person.ts
with Version 1.0.0-alpha.25 or 1.0.0-alpha.26 fails the second time with:Version 1.0.0-alpha.24 works fine.
I think the problem is, that the guard files are not known to the project. In function
generate()
(line 944) the provided path (not the generated guard) is added to the project. ThereforeprocessProject()
doesn't find the generated guards in line 965:and
deleteGuardFile()
is never called. The last assertion is a fact, as I checked it. It's not called in my setup.I'm not providing a PR because I'm not sure how to fix the issue. Maybe extending
generate()
would do the trick: