mirror of
https://github.com/go-task/task.git
synced 2025-06-17 00:17:51 +02:00
Envs should be overridable
System-wide environment variable should have priority. That's how it works for .env files, so this is consistent. Closes #425
This commit is contained in:
13
task.go
13
task.go
@ -397,10 +397,19 @@ func getEnviron(t *taskfile.Task) []string {
|
||||
}
|
||||
|
||||
environ := os.Environ()
|
||||
|
||||
for k, v := range t.Env.ToCacheMap() {
|
||||
if s, ok := v.(string); ok {
|
||||
environ = append(environ, fmt.Sprintf("%s=%s", k, s))
|
||||
str, isString := v.(string)
|
||||
if !isString {
|
||||
continue
|
||||
}
|
||||
|
||||
if _, alreadySet := os.LookupEnv(k); alreadySet {
|
||||
continue
|
||||
}
|
||||
|
||||
environ = append(environ, fmt.Sprintf("%s=%s", k, str))
|
||||
}
|
||||
|
||||
return environ
|
||||
}
|
||||
|
Reference in New Issue
Block a user