Added support for pre and post commands

Two new fields were added to the config. Precmds runs before cmds and
links. Postcmds runs after cmds and links. Cmds is no longer necessary
but was left in for compatibility.
This commit is contained in:
tridentlead 2017-01-04 10:21:35 -05:00
parent 6994b1781d
commit 66eb33b724
No known key found for this signature in database
GPG Key ID: CE37EAE1E94DA098

18
task.go
View File

@ -30,7 +30,9 @@ import (
type task struct { type task struct {
Deps []string Deps []string
Links [][]string Links [][]string
Precmds [][]string
Cmds [][]string Cmds [][]string
Postcmds [][]string
Envs [][]string Envs [][]string
Accepts [][]string Accepts [][]string
Rejects [][]string Rejects [][]string
@ -61,6 +63,14 @@ func (t *task) process(conf *config) error {
} }
} }
if conf.flags&flagNoCmds == 0 {
for _, currCmd := range t.Precmds {
if err := processCmd(currCmd, true, conf); err != nil {
return err
}
}
}
if conf.flags&flagNoCmds == 0 { if conf.flags&flagNoCmds == 0 {
for _, currCmd := range t.Cmds { for _, currCmd := range t.Cmds {
if err := processCmd(currCmd, true, conf); err != nil { if err := processCmd(currCmd, true, conf); err != nil {
@ -77,6 +87,14 @@ func (t *task) process(conf *config) error {
} }
} }
if conf.flags&flagNoCmds == 0 {
for _, currCmd := range t.Postcmds {
if err := processCmd(currCmd, true, conf); err != nil {
return err
}
}
}
return nil return nil
} }