Skip to content

Commit 4595c1e

Browse files
feat: add silent for defer (#1879)
Co-authored-by: Valentin Maerten <[email protected]>
1 parent 1a648de commit 4595c1e

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

task_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,8 +2002,8 @@ cmd ran
20022002
task: [task-2] exit 1
20032003
task: [task-2] echo 'failing' && exit 2
20042004
failing
2005-
task: [task-2] echo 'echo ran'
20062005
echo ran
2006+
task-1 ran successfully
20072007
task: [task-1] echo 'task-1 ran successfully'
20082008
task-1 ran successfully
20092009
`)

taskfile/ast/cmd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ func (c *Cmd) UnmarshalYAML(node *yaml.Node) error {
7575

7676
// A deferred command
7777
var deferredCmd struct {
78-
Defer string
78+
Defer string
79+
Silent bool
7980
}
8081
if err := node.Decode(&deferredCmd); err == nil && deferredCmd.Defer != "" {
8182
c.Defer = true
8283
c.Cmd = deferredCmd.Defer
84+
c.Silent = deferredCmd.Silent
8385
return nil
8486
}
8587

@@ -91,6 +93,7 @@ func (c *Cmd) UnmarshalYAML(node *yaml.Node) error {
9193
c.Defer = true
9294
c.Task = deferredCall.Defer.Task
9395
c.Vars = deferredCall.Defer.Vars
96+
c.Silent = deferredCall.Defer.Silent
9497
return nil
9598
}
9699

testdata/deferred/Taskfile.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
version: "3"
1+
version: '3'
22

33
tasks:
44
task-1:
55
- echo 'task-1 ran {{.PARAM}}'
66

77
task-2:
8-
- defer: { task: "task-1", vars: { PARAM: "successfully" } }
8+
- defer: { task: 'task-1', vars: { PARAM: 'successfully' } }
9+
- defer: { task: 'task-1', vars: { PARAM: 'successfully' }, silent: true }
910
- defer: echo 'echo ran'
11+
silent: true
1012
- defer: echo 'failing' && exit 2
1113
- echo 'cmd ran'
1214
- exit 1

0 commit comments

Comments
 (0)