1
0
mirror of https://github.com/go-task/task.git synced 2025-01-04 03:48:02 +02:00
task/internal/env/env.go
Pete Davison 247c2586c2
refactor: taskfile/ast package (#1450)
* refactor: ast package

* feat: read -> taskfile

* refactor: taskfile.Taskfile -> taskfile.Read

* refactor: move merge function back into taskfile package

* refactor: rename taskfile.go to read.go
2023-12-29 20:32:03 +00:00

32 lines
430 B
Go

package env
import (
"fmt"
"os"
"github.com/go-task/task/v3/taskfile/ast"
)
func Get(t *ast.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
}