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.
This commit is contained in:
parent
1e7b63814f
commit
8586d930a3
|
@ -3,6 +3,7 @@ package config
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
@ -40,5 +41,15 @@ func Read(f string) (*Config, error) {
|
||||||
return nil, fmt.Errorf("parsing config: %w", err)
|
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
|
return &c, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue