1
0
mirror of https://github.com/go-task/task.git synced 2024-12-12 10:45:49 +02:00

feat: add silent for defer (#1879)

Co-authored-by: Valentin Maerten <maerten.valentin@gmail.com>
This commit is contained in:
Danilo Bürger 2024-12-07 16:16:27 +01:00 committed by GitHub
parent 1a648dea50
commit 4595c1e32a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -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
`)

View File

@ -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
}
@ -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
}

View File

@ -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