From cf58e9a722f8b29b5e7cfbf1990a7972c9d22481 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 20 Nov 2025 13:06:31 +0100 Subject: [PATCH] Add environment variables to evaluation scope The prepareScope function now includes all environment variables in the returned scope under the 'env' key. This allows scripts and evaluations to access environment variables during execution. --- regolith/evaluator.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/regolith/evaluator.go b/regolith/evaluator.go index 3f9e5433..a271561a 100644 --- a/regolith/evaluator.go +++ b/regolith/evaluator.go @@ -1,7 +1,9 @@ package regolith import ( + "os" "runtime" + "strings" "github.com/Bedrock-OSS/go-burrito/burrito" "github.com/stirante/go-simple-eval/eval" @@ -51,6 +53,13 @@ func prepareScope(ctx RunContext) map[string]any { if ctx.IsInWatchMode() { mode = "watch" } + // Collect all environment variables + envVars := make(map[string]any) + for _, env := range os.Environ() { + if pair := strings.SplitN(env, "=", 2); len(pair) == 2 { + envVars[pair[0]] = pair[1] + } + } return map[string]any{ "os": runtime.GOOS, "arch": runtime.GOARCH, @@ -62,5 +71,6 @@ func prepareScope(ctx RunContext) map[string]any { "project": projectData, "mode": mode, "initial": ctx.Initial, + "env": envVars, } }