From fea0250aa0f37d55ad2bb6730bf6090c3bde0762 Mon Sep 17 00:00:00 2001 From: alessio Date: Mon, 7 Aug 2017 23:01:02 +0200 Subject: [PATCH] #51 fixed --- watcher/cmd.go | 9 +++++++++ watcher/main.go | 17 +++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/watcher/cmd.go b/watcher/cmd.go index 84b96a2..4ad0d1d 100644 --- a/watcher/cmd.go +++ b/watcher/cmd.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/tockins/realize/style" cli "gopkg.in/urfave/cli.v2" + "os" "strings" ) @@ -51,6 +52,14 @@ func (h *Blueprint) Run(p *cli.Context) error { h.Projects[k].tools = tools h.Projects[k].parent = h h.Projects[k].path = h.Projects[k].Path + + // env variables + for key, item := range h.Projects[k].Environment { + if err := os.Setenv(key, item); err != nil{ + h.Projects[k].Buffer.StdErr = append(h.Projects[k].Buffer.StdErr, err) + } + } + if h.Legacy.Status { go h.Projects[k].watchByPolling() } else { diff --git a/watcher/main.go b/watcher/main.go index 07c42c7..9696350 100644 --- a/watcher/main.go +++ b/watcher/main.go @@ -34,14 +34,15 @@ type Project struct { settings.Settings `yaml:"-"` LastChangedOn time.Time `yaml:"-" json:"-"` base string - Name string `yaml:"name" json:"name"` - Path string `yaml:"path" json:"path"` - Cmds Cmds `yaml:"commands" json:"commands"` - Args []string `yaml:"args,omitempty" json:"args,omitempty"` - Watcher Watcher `yaml:"watcher" json:"watcher"` - Streams Streams `yaml:"streams,omitempty" json:"streams,omitempty"` - Buffer Buffer `yaml:"-" json:"buffer"` - ErrorOutputPattern string `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"` + Name string `yaml:"name" json:"name"` + Path string `yaml:"path" json:"path"` + Environment map[string]string `yaml:"environment" json:"environment"` + Cmds Cmds `yaml:"commands" json:"commands"` + Args []string `yaml:"args,omitempty" json:"args,omitempty"` + Watcher Watcher `yaml:"watcher" json:"watcher"` + Streams Streams `yaml:"streams,omitempty" json:"streams,omitempty"` + Buffer Buffer `yaml:"-" json:"buffer"` + ErrorOutputPattern string `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"` parent *Blueprint path string tools tools