Skip to content

Commit

Permalink
fix: include dir
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaerten committed Jul 5, 2024
1 parent 23542f1 commit d90b650
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
21 changes: 9 additions & 12 deletions taskfile/ast/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ast

import (
"fmt"
"path"
"strings"

"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -86,19 +85,18 @@ func (t1 *Tasks) Merge(t2 Tasks, include *Include, includedTaskfileVars *Vars) e
}
}

if include.AdvancedImport {
task.Dir = filepathext.SmartJoin(include.Dir, task.Dir)
if task.IncludeVars == nil {
task.IncludeVars = &Vars{}
}
task.IncludeVars.Merge(include.Vars, nil)
task.IncludedTaskfileVars = includedTaskfileVars.DeepCopy()
}
taskName = taskNameWithNamespace(name, include.Namespace)
task.Namespace = include.Namespace
task.Task = taskName
} else {
task.Dir = path.Join(include.Dir, task.Dir)
}

if include.AdvancedImport {
task.Dir = filepathext.SmartJoin(include.Dir, task.Dir)
if task.IncludeVars == nil {
task.IncludeVars = &Vars{}
}
task.IncludeVars.Merge(include.Vars, nil)
task.IncludedTaskfileVars = includedTaskfileVars.DeepCopy()
}

if t1.Get(taskName) != nil {
Expand Down Expand Up @@ -153,7 +151,6 @@ func (t *Tasks) UnmarshalYAML(node *yaml.Node) error {
}
}
}
tasks.Set(name, task)
return nil
})

Expand Down
1 change: 1 addition & 0 deletions testdata/includes_flatten/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: '3'
includes:
included:
taskfile: ./included
dir: ./included
flatten: true

tasks:
Expand Down
6 changes: 6 additions & 0 deletions testdata/includes_flatten/included/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ tasks:
- gen
cmds:
- echo "with_deps from included"


pwd:
desc: Print working directory
cmds:
- pwd

0 comments on commit d90b650

Please sign in to comment.