Skip to content

Commit

Permalink
fix: ensure relative paths can be processed, fixes #570
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Mar 1, 2024
1 parent 8f039c9 commit edb6b55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.596
0.2.598
6 changes: 5 additions & 1 deletion cmd/templ/generatecmd/eventhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ func (h *FSEventHandler) generate(ctx context.Context, fileName string) (goUpdat
targetFileName := strings.TrimSuffix(fileName, ".templ") + "_templ.go"

// Only use relative filenames to the basepath for filenames in runtime error messages.
relFilePath, err := filepath.Rel(h.dir, fileName)
absFilePath, err := filepath.Abs(fileName)
if err != nil {
return false, false, nil, fmt.Errorf("failed to get absolute path for %q: %w", fileName, err)
}
relFilePath, err := filepath.Rel(h.dir, absFilePath)
if err != nil {
return false, false, nil, fmt.Errorf("failed to get relative path for %q: %w", fileName, err)
}
Expand Down

0 comments on commit edb6b55

Please sign in to comment.