Skip to content

Commit

Permalink
feat: add silent for defer (#1879)
Browse files Browse the repository at this point in the history
Co-authored-by: Valentin Maerten <[email protected]>
  • Loading branch information
danilobuerger and vmaerten authored Dec 7, 2024
1 parent 1a648de commit 4595c1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,8 @@ cmd ran
task: [task-2] exit 1
task: [task-2] echo 'failing' && exit 2
failing
task: [task-2] echo 'echo ran'
echo ran
task-1 ran successfully
task: [task-1] echo 'task-1 ran successfully'
task-1 ran successfully
`)
Expand Down
5 changes: 4 additions & 1 deletion taskfile/ast/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ func (c *Cmd) UnmarshalYAML(node *yaml.Node) error {

// A deferred command
var deferredCmd struct {
Defer string
Defer string
Silent bool
}
if err := node.Decode(&deferredCmd); err == nil && deferredCmd.Defer != "" {
c.Defer = true
c.Cmd = deferredCmd.Defer
c.Silent = deferredCmd.Silent
return nil
}

Expand All @@ -91,6 +93,7 @@ func (c *Cmd) UnmarshalYAML(node *yaml.Node) error {
c.Defer = true
c.Task = deferredCall.Defer.Task
c.Vars = deferredCall.Defer.Vars
c.Silent = deferredCall.Defer.Silent
return nil
}

Expand Down
6 changes: 4 additions & 2 deletions testdata/deferred/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "3"
version: '3'

tasks:
task-1:
- echo 'task-1 ran {{.PARAM}}'

task-2:
- defer: { task: "task-1", vars: { PARAM: "successfully" } }
- defer: { task: 'task-1', vars: { PARAM: 'successfully' } }
- defer: { task: 'task-1', vars: { PARAM: 'successfully' }, silent: true }
- defer: echo 'echo ran'
silent: true
- defer: echo 'failing' && exit 2
- echo 'cmd ran'
- exit 1

0 comments on commit 4595c1e

Please sign in to comment.