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

32
task.go
View File

@ -28,12 +28,14 @@ import (
)
type task struct {
Deps []string
Links [][]string
Cmds [][]string
Envs [][]string
Accepts [][]string
Rejects [][]string
Deps []string
Links [][]string
Precmds [][]string
Cmds [][]string
Postcmds [][]string
Envs [][]string
Accepts [][]string
Rejects [][]string
}
func (t *task) deps(conf *config) []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 {
for _, currCmd := range t.Cmds {
if err := processCmd(currCmd, true, conf); err != nil {
@ -77,7 +87,15 @@ func (t *task) process(conf *config) error {
}
}
return nil
if conf.flags&flagNoCmds == 0 {
for _, currCmd := range t.Postcmds {
if err := processCmd(currCmd, true, conf); err != nil {
return err
}
}
}
return nil
}
func (t *task) skippable(conf *config) bool {