Skip to content

Commit

Permalink
Add support for single-cmd tasks (fixes #1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
timdp committed Apr 20, 2023
1 parent c252379 commit bb8f99d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1892,3 +1892,15 @@ func TestSplitArgs(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "3\n", buff.String())
}

func TestSingleCmdDep(t *testing.T) {
tt := fileContentTest{
Dir: "testdata/single_cmd_dep",
Target: "foo",
Files: map[string]string{
"foo.txt": "foo\n",
"bar.txt": "bar\n",
},
}
tt.Run(t)
}
7 changes: 6 additions & 1 deletion taskfile/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
case yaml.MappingNode:
var task struct {
Cmds []*Cmd
Cmd *Cmd
Deps []*Dep
Label string
Desc string
Expand Down Expand Up @@ -100,7 +101,11 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
if err := node.Decode(&task); err != nil {
return err
}
t.Cmds = task.Cmds
if task.Cmd != nil {
t.Cmds = []*Cmd{task.Cmd}
} else {
t.Cmds = task.Cmds
}
t.Deps = task.Deps
t.Label = task.Label
t.Desc = task.Desc
Expand Down
1 change: 1 addition & 0 deletions testdata/single_cmd_dep/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.txt
8 changes: 8 additions & 0 deletions testdata/single_cmd_dep/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"

tasks:
foo:
deps: [bar]
cmd: echo foo > foo.txt

bar: echo bar > bar.txt

0 comments on commit bb8f99d

Please sign in to comment.