1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Fix bug of Task not executing the "default" task

When global vars were informed using the CLI.

I took the oportunity to move this logic to the proper package and
write a test.
This commit is contained in:
Andrey Nering
2019-12-07 16:20:36 -03:00
parent f0bc4d26a0
commit a4685229c9
4 changed files with 17 additions and 7 deletions

View File

@@ -5,6 +5,8 @@
- Add `--parallel` flag (alias `-p`) to run tasks given by the command line in
parallel
([#266](https://github.com/go-task/task/pull/266)).
- Fixed bug where calling the `task` CLI only informing global vars would not
execute the `default` task.
## v2.7.1 - 2019-11-10

View File

@@ -133,13 +133,7 @@ func main() {
return
}
arguments := pflag.Args()
if len(arguments) == 0 {
log.Println("task: No argument given, trying default task")
arguments = []string{"default"}
}
calls, globals := args.Parse(arguments...)
calls, globals := args.Parse(pflag.Args()...)
for name, value := range globals {
e.Taskfile.Vars[name] = value
}

View File

@@ -34,6 +34,10 @@ func Parse(args ...string) ([]taskfile.Call, taskfile.Vars) {
}
}
if len(calls) == 0 {
calls = append(calls, taskfile.Call{Task: "default"})
}
return calls, globals
}

View File

@@ -64,6 +64,16 @@ func TestArgs(t *testing.T) {
"FOO": {Static: "bar"},
},
},
{
Args: []string{"FOO=bar", "BAR=baz"},
ExpectedCalls: []taskfile.Call{
{Task: "default"},
},
ExpectedGlobals: taskfile.Vars{
"FOO": {Static: "bar"},
"BAR": {Static: "baz"},
},
},
}
for i, test := range tests {