-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: default to delete orphaned files, with -keepOrphanedFiles argument flag to disable feature #325
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this, I think it would be best to move the behaviour though, unless I'm missing something?
cmd/templ/generatecmd/main.go
Outdated
@@ -125,6 +125,38 @@ func runCmd(ctx context.Context, w io.Writer, args Arguments) (err error) { | |||
p = proxy.New(args.ProxyPort, target) | |||
} | |||
|
|||
if !args.KeepOrphanedFiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right place to do this work, because it means walking through the directory tree twice which is relatively expensive to do.
If we can combine the deletion of orphaned files with the generation, I think that would be better. Also, I'm wondering if the deletion of the orphaned file should be a warning or some other level to make it stand out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% right, I was on something. Passed the argument to the processFile function (would that be the way?), checked it and used logWarning for the message.
Fixed with your helpful direction. Lmk if it still needs some work! |
Added default functionality to delete orphans on
templ generate
& with the -keep-orphaned-files arg flag
(base2_templ.go isn't deleted)