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:
parent
1a648dea50
commit
4595c1e32a
@ -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
|
||||
`)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
6
testdata/deferred/Taskfile.yml
vendored
6
testdata/deferred/Taskfile.yml
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user