mirror of
https://github.com/go-task/task.git
synced 2024-12-16 10:59:23 +02:00
32 lines
431 B
Go
32 lines
431 B
Go
package env
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/go-task/task/v3/taskfile"
|
|
)
|
|
|
|
func Get(t *taskfile.Task) []string {
|
|
if t.Env == nil {
|
|
return nil
|
|
}
|
|
|
|
environ := os.Environ()
|
|
|
|
for k, v := range t.Env.ToCacheMap() {
|
|
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
|
|
}
|