air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
16.35k stars 771 forks source link

Wait X amount of time before looking for new changes #527

Open randallmlough opened 4 months ago

randallmlough commented 4 months ago

Is there a way I can delay air from looking for changes after a rebuild? I run code generation (graphql code generation) before each rebuild, and one of the generated directories (resolvers) is non-destructive and intended to be edited. It doesnt overwrite what is currently there, just appends if needed. However, if I dont exclude this directory from being watched, I get stuck in an infinite loop of codegen -> rebuild -> codegen -> rebuild, etc.

Ideally I'm hoping there's a setting or combination of settings where I can tell air to disregard any changes prior to this amount of time thereby allowing code generation to happen without re triggering a rebuild.

I've tried messing with delay, rebuild_delay and a mixture of other combinations without any luck.

namzug16 commented 3 months ago

It seems that you need to exclude all the generated files from templ like so

exclude_regex = [".*_templ.go"]

and for some reason when putting the templ generate command as a pre_cmd it gives still the error, so I did this

cmd = "templ generate && go build -o ./tmp/main ."

and everything worked perfectly.

Hope it helps