summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Daniele Sluijters <daenney@users.noreply.github.com>2023-01-03 14:35:36 +0100
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2023-02-05 12:45:46 +0200
commit8586d930a3f4a8235d6383e90bbcd22762060126 (patch)
treed15bc08c541687aaf5a50ff275d293a30fa0a211
parent1e7b63814fc003577e14356c79793cc827661270 (diff)
downloadlegit-8586d930a3f4a8235d6383e90bbcd22762060126.tar.gz
legit-8586d930a3f4a8235d6383e90bbcd22762060126.tar.bz2
legit-8586d930a3f4a8235d6383e90bbcd22762060126.zip
config: Ensure we always have an absolute path
Having this consistent across the code is handy when we're building paths, counting separators and other path manipulation.
-rw-r--r--config/config.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
index 3119352..7c38341 100644
--- a/config/config.go
+++ b/config/config.go
@@ -3,6 +3,7 @@ package config
import (
"fmt"
"os"
+ "path/filepath"
"gopkg.in/yaml.v3"
)
@@ -40,5 +41,15 @@ func Read(f string) (*Config, error) {
return nil, fmt.Errorf("parsing config: %w", err)
}
+ if c.Repo.ScanPath, err = filepath.Abs(c.Repo.ScanPath); err != nil {
+ return nil, err
+ }
+ if c.Dirs.Templates, err = filepath.Abs(c.Dirs.Templates); err != nil {
+ return nil, err
+ }
+ if c.Dirs.Static, err = filepath.Abs(c.Dirs.Static); err != nil {
+ return nil, err
+ }
+
return &c, nil
}