mirror of
https://github.com/go-task/task.git
synced 2025-01-26 05:27:15 +02:00
Removed automatic inclusion of Taskfiles by OS and update tests
This commit is contained in:
parent
a3464068bd
commit
f38ba7fcd3
@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/go-task/task/v2/internal/taskfile"
|
||||
|
||||
@ -46,21 +45,10 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
|
||||
return nil, ErrIncludedTaskfilesCantHaveIncludes
|
||||
}
|
||||
|
||||
includedTaskDirectory := filepath.Dir(path)
|
||||
includedTaskfileName := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
|
||||
path = filepath.Join(includedTaskDirectory, fmt.Sprintf("%s_%s.yml", includedTaskfileName, runtime.GOOS))
|
||||
if _, err = os.Stat(path); err == nil {
|
||||
osIncludedTaskfile, err := readTaskfile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = taskfile.Merge(includedTaskfile, osIncludedTaskfile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, task := range includedTaskfile.Tasks {
|
||||
task.Dir = filepath.Join(includedTask.Dir, task.Dir)
|
||||
if !filepath.IsAbs(task.Dir) {
|
||||
task.Dir = filepath.Join(includedTask.Dir, task.Dir)
|
||||
}
|
||||
}
|
||||
|
||||
if err = taskfile.Merge(t, includedTaskfile, namespace); err != nil {
|
||||
|
@ -546,7 +546,6 @@ func TestIncludes(t *testing.T) {
|
||||
"included_taskfile_without_dir.txt": "included_taskfile_without_dir",
|
||||
"./module2/included_directory_with_dir.txt": "included_directory_with_dir",
|
||||
"./module2/included_taskfile_with_dir.txt": "included_taskfile_with_dir",
|
||||
"./module3/os_related.txt": runtime.GOOS,
|
||||
},
|
||||
}
|
||||
tt.Run(t)
|
||||
|
6
testdata/includes/Taskfile.yml
vendored
6
testdata/includes/Taskfile.yml
vendored
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: '3'
|
||||
|
||||
includes:
|
||||
included: ./included
|
||||
@ -13,9 +13,6 @@ includes:
|
||||
included_taskfile_with_dir:
|
||||
taskfile: ./module2/Taskfile.yml
|
||||
dir: ./module2
|
||||
os_related:
|
||||
taskfile: ./module3/CustomTaskfile.yml
|
||||
dir: ./module3
|
||||
|
||||
tasks:
|
||||
default:
|
||||
@ -27,7 +24,6 @@ tasks:
|
||||
- task: included_taskfile_without_dir:gen_dir
|
||||
- task: included_with_dir:gen_file
|
||||
- task: included_taskfile_with_dir:gen_dir
|
||||
- task: os_related:gen
|
||||
|
||||
gen:
|
||||
cmds:
|
||||
|
2
testdata/includes/Taskfile2.yml
vendored
2
testdata/includes/Taskfile2.yml
vendored
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
|
2
testdata/includes/included/Taskfile.yml
vendored
2
testdata/includes/included/Taskfile.yml
vendored
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
|
3
testdata/includes/module1/Taskfile.yml
vendored
3
testdata/includes/module1/Taskfile.yml
vendored
@ -1,9 +1,10 @@
|
||||
version: '2'
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
gen_dir:
|
||||
cmds:
|
||||
- echo included_directory_without_dir > included_directory_without_dir.txt
|
||||
|
||||
gen_file:
|
||||
cmds:
|
||||
- echo included_taskfile_without_dir > included_taskfile_without_dir.txt
|
||||
|
3
testdata/includes/module2/Taskfile.yml
vendored
3
testdata/includes/module2/Taskfile.yml
vendored
@ -1,9 +1,10 @@
|
||||
version: '2'
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
gen_dir:
|
||||
cmds:
|
||||
- echo included_directory_with_dir > included_directory_with_dir.txt
|
||||
|
||||
gen_file:
|
||||
cmds:
|
||||
- echo included_taskfile_with_dir > included_taskfile_with_dir.txt
|
||||
|
6
testdata/includes/module3/CustomTaskfile.yml
vendored
6
testdata/includes/module3/CustomTaskfile.yml
vendored
@ -1,6 +0,0 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
cmds:
|
||||
- echo "INVALID" > os_related.txt
|
@ -1,6 +0,0 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
cmds:
|
||||
- echo "darwin" > os_related.txt
|
@ -1,6 +0,0 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
cmds:
|
||||
- echo "linux" > os_related.txt
|
@ -1,6 +0,0 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
cmds:
|
||||
- echo "windows" > os_related.txt
|
Loading…
x
Reference in New Issue
Block a user