mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
Merge pull request #172 from go-task/allow-calling-root-task-from-included
Allow calling a task of the root Taskfile from within an included Taskfile
This commit is contained in:
commit
2cb070f5b3
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- Allow calling a task of the root Taskfile from an included Taskfile
|
||||||
|
by prefixing it with `:`
|
||||||
|
([#161](https://github.com/go-task/task/issues/161), [#172](https://github.com/go-task/task/issues/172)).
|
||||||
|
|
||||||
## v2.3.0 - 2019-01-02
|
## v2.3.0 - 2019-01-02
|
||||||
|
|
||||||
- On Windows, Task can now be installed using [Scoop](https://scoop.sh/)
|
- On Windows, Task can now be installed using [Scoop](https://scoop.sh/)
|
||||||
|
@ -258,6 +258,10 @@ tasks:
|
|||||||
|
|
||||||
The above syntax is also supported in `deps`.
|
The above syntax is also supported in `deps`.
|
||||||
|
|
||||||
|
> NOTE: If you want to call a task declared in the root Taskfile from within an
|
||||||
|
> [included Taskfile](#including-other-taskfiles), add a leading `:` like this:
|
||||||
|
> `task: :task-name`.
|
||||||
|
|
||||||
## Prevent unnecessary work
|
## Prevent unnecessary work
|
||||||
|
|
||||||
If a task generates something, you can inform Task the source and generated
|
If a task generates something, you can inform Task the source and generated
|
||||||
|
@ -66,5 +66,8 @@ func Merge(t1, t2 *Taskfile, namespaces ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func taskNameWithNamespace(taskName string, namespaces ...string) string {
|
func taskNameWithNamespace(taskName string, namespaces ...string) string {
|
||||||
|
if strings.HasPrefix(taskName, ":") {
|
||||||
|
return strings.TrimPrefix(taskName, ":")
|
||||||
|
}
|
||||||
return strings.Join(append(namespaces, taskName), NamespaceSeparator)
|
return strings.Join(append(namespaces, taskName), NamespaceSeparator)
|
||||||
}
|
}
|
||||||
|
12
task_test.go
12
task_test.go
@ -511,3 +511,15 @@ func TestIncludesDependencies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tt.Run(t)
|
tt.Run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIncludesCallingRoot(t *testing.T) {
|
||||||
|
tt := fileContentTest{
|
||||||
|
Dir: "testdata/includes_call_root_task",
|
||||||
|
Target: "included:call-root",
|
||||||
|
TrimSpace: true,
|
||||||
|
Files: map[string]string{
|
||||||
|
"root_task.txt": "root task",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
tt.Run(t)
|
||||||
|
}
|
||||||
|
1
testdata/includes_call_root_task/.gitignore
vendored
Normal file
1
testdata/includes_call_root_task/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.txt
|
9
testdata/includes_call_root_task/Taskfile.yml
vendored
Normal file
9
testdata/includes_call_root_task/Taskfile.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
includes:
|
||||||
|
included: Taskfile2.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
root-task:
|
||||||
|
cmds:
|
||||||
|
- echo "root task" > root_task.txt
|
6
testdata/includes_call_root_task/Taskfile2.yml
vendored
Normal file
6
testdata/includes_call_root_task/Taskfile2.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
call-root:
|
||||||
|
cmds:
|
||||||
|
- task: :root-task
|
Loading…
Reference in New Issue
Block a user