11package parser
22
33import (
4- "context"
54 "fmt"
65 "os"
76 "path/filepath"
87
9- "github.com/nxtcoder17/go.pkgs/log"
108 "github.com/nxtcoder17/runfile/errors"
119 fn "github.com/nxtcoder17/runfile/functions"
1210 "github.com/nxtcoder17/runfile/types"
@@ -18,25 +16,28 @@ func parseRunfile(ctx types.Context, runfile *types.Runfile) (*types.ParsedRunfi
1816 Env : make (map [string ]string ),
1917 Tasks : make (map [string ]types.Task ),
2018 }
19+ prf .Metadata .RunfilePath = runfile .Filepath
2120
2221 for k , task := range runfile .Tasks {
2322 task .Name = k
23+ task .Metadata .RunfilePath = & prf .Metadata .RunfilePath
2424 prf .Tasks [k ] = task
2525 }
2626
27- m , err := parseIncludes (ctx , runfile .Includes )
27+ includes , err := parseIncludes (ctx , runfile .Includes )
2828 if err != nil {
2929 return nil , err
3030 }
3131
32- for k , iprf := range m {
33- for taskName , task := range iprf .Tasks {
34- task .Name = k
35- task .Metadata .RunfilePath = & iprf .Metadata .RunfilePath
32+ for k , included := range includes {
33+ for taskName , task := range included .Tasks {
34+ task .Name = taskName
35+ task .Metadata .RunfilePath = & included .Metadata .RunfilePath
36+ task .Metadata .Namespace = k
3637 prf .Tasks [fmt .Sprintf ("%s:%s" , k , taskName )] = task
3738 }
3839
39- for k , v := range iprf .Env {
40+ for k , v := range included .Env {
4041 prf .Env [k ] = v
4142 }
4243 }
@@ -58,7 +59,7 @@ func parseRunfile(ctx types.Context, runfile *types.Runfile) (*types.ParsedRunfi
5859 return nil , err
5960 }
6061
61- envVars , err := parseEnvVars (types. Context { Context : context . TODO (), Logger : log . New ()} , runfile .Env , evaluationParams {Env : dotenvVars })
62+ envVars , err := parseEnvVars (ctx , runfile .Env , evaluationParams {Env : dotenvVars })
6263 if err != nil {
6364 return nil , err
6465 }
@@ -86,9 +87,6 @@ func parseRunfileFromFile(ctx types.Context, file string) (*types.ParsedRunfile,
8687 if err != nil {
8788 return nil , err
8889 }
89-
90- // prf.Metadata.RunfilePath = file
91- prf .Metadata .RunfilePath = fn .Must (filepath .Abs (file ))
9290 return prf , nil
9391}
9492
0 commit comments