mirror of
https://github.com/go-task/task.git
synced 2025-12-16 11:47:44 +01: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:
@@ -5,6 +5,8 @@
|
|||||||
- Add `--parallel` flag (alias `-p`) to run tasks given by the command line in
|
- Add `--parallel` flag (alias `-p`) to run tasks given by the command line in
|
||||||
parallel
|
parallel
|
||||||
([#266](https://github.com/go-task/task/pull/266)).
|
([#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
|
## v2.7.1 - 2019-11-10
|
||||||
|
|
||||||
|
|||||||
@@ -133,13 +133,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
arguments := pflag.Args()
|
calls, globals := args.Parse(pflag.Args()...)
|
||||||
if len(arguments) == 0 {
|
|
||||||
log.Println("task: No argument given, trying default task")
|
|
||||||
arguments = []string{"default"}
|
|
||||||
}
|
|
||||||
|
|
||||||
calls, globals := args.Parse(arguments...)
|
|
||||||
for name, value := range globals {
|
for name, value := range globals {
|
||||||
e.Taskfile.Vars[name] = value
|
e.Taskfile.Vars[name] = value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
return calls, globals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,16 @@ func TestArgs(t *testing.T) {
|
|||||||
"FOO": {Static: "bar"},
|
"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 {
|
for i, test := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user