From 66eb33b7246295b53b097ea252695204d8514dfd Mon Sep 17 00:00:00 2001 From: tridentlead Date: Wed, 4 Jan 2017 10:21:35 -0500 Subject: [PATCH] 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. --- task.go | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/task.go b/task.go index f99c358..2619905 100644 --- a/task.go +++ b/task.go @@ -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 {