Skip to content
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

Merged
merged 9 commits into from
Dec 17, 2023

Conversation

YiumPotato
Copy link
Contributor

Added default functionality to delete orphans on templ generate
image
& with the -keep-orphaned-files arg flag
image
(base2_templ.go isn't deleted)

Copy link
Owner

@a-h a-h left a 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?

@@ -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 {
Copy link
Owner

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.

Copy link
Contributor Author

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.

cmd/templ/generatecmd/main.go Outdated Show resolved Hide resolved
@YiumPotato
Copy link
Contributor Author

Fixed with your helpful direction. Lmk if it still needs some work!

cmd/templ/generatecmd/main.go Outdated Show resolved Hide resolved
cmd/templ/generatecmd/main.go Outdated Show resolved Hide resolved
cmd/templ/generatecmd/main.go Outdated Show resolved Hide resolved
@a-h a-h merged commit 13b1f8a into a-h:main Dec 17, 2023
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants