Skip to content

Commit

Permalink
fix: only run the version check once per command, to avoid spam.
Browse files Browse the repository at this point in the history
  • Loading branch information
joerdav committed Jan 19, 2024
1 parent a5d64fa commit 274e48c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cmd/templ/generatecmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func runCmd(ctx, watchCtx context.Context, w io.Writer, args Arguments) error {
}
fmt.Fprintln(w, "Processing path:", args.Path)

if err := checkTemplVersion(args.Path); err != nil {
logWarning(w, "templ version check failed: %v\n", err)
}

if args.Watch {
err = generateWatched(watchCtx, w, args, opts, p)
if err != nil && !errors.Is(err, context.Canceled) {
Expand Down Expand Up @@ -218,9 +222,6 @@ func generateWatched(ctx context.Context, w io.Writer, args Arguments, opts []ge
}()
}
}
if err := checkTemplVersion(args.Path); err != nil {
logWarning(w, "templ version check failed: %v\n", err)
}

if firstRunComplete {
if changesFound > 0 {
Expand Down Expand Up @@ -265,10 +266,6 @@ func generateProduction(ctx context.Context, w io.Writer, args Arguments, opts [
}
}

if err := checkTemplVersion(args.Path); err != nil {
logWarning(w, "templ version check failed: %v\n", err)
}

return nil
}

Expand Down

0 comments on commit 274e48c

Please sign in to comment.