Allow multiple projects to have different values for same env var
This commit is contained in:
parent
05f079e472
commit
37a6dbf977
|
@ -116,12 +116,6 @@ func (p *Project) Before() {
|
||||||
}
|
}
|
||||||
// setup go tools
|
// setup go tools
|
||||||
p.Tools.Setup()
|
p.Tools.Setup()
|
||||||
// set env const
|
|
||||||
for key, item := range p.Env {
|
|
||||||
if err := os.Setenv(key, item); err != nil {
|
|
||||||
p.Buffer.StdErr = append(p.Buffer.StdErr, BufferOut{Time: time.Now(), Text: err.Error(), Type: "Env error", Stream: ""})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// global commands before
|
// global commands before
|
||||||
p.cmd(p.stop, "before", true)
|
p.cmd(p.stop, "before", true)
|
||||||
// indexing files and dirs
|
// indexing files and dirs
|
||||||
|
@ -563,6 +557,13 @@ func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p Project) buildEnvs() (envs []string) {
|
||||||
|
for k, v := range p.Env {
|
||||||
|
envs = append(envs, fmt.Sprintf("%s=%s", strings.Replace(k, "=", "", -1), v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Run a project
|
// Run a project
|
||||||
func (p *Project) run(path string, stream chan Response, stop <-chan bool) (err error) {
|
func (p *Project) run(path string, stream chan Response, stop <-chan bool) (err error) {
|
||||||
var args []string
|
var args []string
|
||||||
|
@ -625,6 +626,10 @@ func (p *Project) run(path string, stream chan Response, stop <-chan bool) (err
|
||||||
return errors.New("project not found")
|
return errors.New("project not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
appendEnvs := p.buildEnvs()
|
||||||
|
if len(appendEnvs) > 0 {
|
||||||
|
build.Env = append(build.Env, appendEnvs...)
|
||||||
|
}
|
||||||
// scan project stream
|
// scan project stream
|
||||||
stdout, err := build.StdoutPipe()
|
stdout, err := build.StdoutPipe()
|
||||||
stderr, err := build.StderrPipe()
|
stderr, err := build.StderrPipe()
|
||||||
|
|
|
@ -44,18 +44,6 @@ func TestProject_Before(t *testing.T) {
|
||||||
if !strings.Contains(buf.String(), input) {
|
if !strings.Contains(buf.String(), input) {
|
||||||
t.Error("Unexpected error")
|
t.Error("Unexpected error")
|
||||||
}
|
}
|
||||||
|
|
||||||
r = Realize{}
|
|
||||||
r.Projects = append(r.Projects, Project{
|
|
||||||
parent: &r,
|
|
||||||
Env: map[string]string{
|
|
||||||
input: input,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
r.Projects[0].Before()
|
|
||||||
if os.Getenv(input) != input {
|
|
||||||
t.Error("Unexpected error expected", input, "instead", os.Getenv(input))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProject_Err(t *testing.T) {
|
func TestProject_Err(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue