mirror of
https://github.com/go-task/task.git
synced 2025-01-04 03:48:02 +02:00
247c2586c2
* 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
32 lines
430 B
Go
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
|
|
}
|