Improve path management

This commit is contained in:
Miguel de la Cruz 2024-07-05 17:24:12 +02:00
parent 2a17689a9f
commit 79de743e58
2 changed files with 32 additions and 1 deletions

View file

@ -170,6 +170,10 @@ func main() {
}
}
func isExcluded(name string) bool {
return strings.HasPrefix(strings.ToUpper(name), "README")
}
func (g *generateCmd) Run() error {
fi, err := os.Stat(g.Output)
if err != nil && !os.IsNotExist(err) {
@ -189,7 +193,22 @@ func (g *generateCmd) Run() error {
walkErr := filepath.WalkDir(g.Path, func(path string, d fs.DirEntry, err error) error {
slog.Debug("Walking through file", "path", path)
relpath := filepath.Join(strings.Split(path, "/")[1:]...)
if isExcluded(d.Name()) {
slog.Debug("Excluded file, skipping", "name", d.Name())
return nil
}
apath, err := filepath.Abs(path)
if err != nil {
return fmt.Errorf("cannot get the abs path for %q: %w", path, err)
}
relpath, err := filepath.Rel(g.Path, apath)
if err != nil {
return fmt.Errorf("cannot get relative path for %s: %w", apath, err)
}
ext := filepath.Ext(d.Name())
recipeName := strings.TrimSuffix(d.Name(), ext)
if d.IsDir() {

View file

@ -2,3 +2,15 @@ body {
background-color: lightgrey;
font-family: monospace;
}
.ingredient {
color: green;
}
.cookware {
color: red;
}
.timer {
color: blue;
}