diff --git a/internal/cuegen/v1alpha2/main.go b/internal/cuegen/v1alpha2/main.go index 481a3c6..b1b786b 100644 --- a/internal/cuegen/v1alpha2/main.go +++ b/internal/cuegen/v1alpha2/main.go @@ -61,6 +61,8 @@ type Cuegen struct { EmptyDir string } +var cuegenProcess = regexp.MustCompile("(?m)^//cuegen: process$") + func (cg Cuegen) Exec() error { emptyDir := "" @@ -177,9 +179,7 @@ func (cg Cuegen) buildLoadConfig(emptydir string) (*load.Config, error) { output := string(data) - rx := regexp.MustCompile("(?m)^//cuegen: process$") - if rx.MatchString(output) { - log.Printf("Process: [%v] %v", pack.Name, filename) + if cuegenProcess.MatchString(output) { p := cuepp.CuePP{ Tempdir: emptydir, Debug: true, diff --git a/tests/v1alpha2/local/readfile.txtar b/tests/v1alpha2/local/readfile.txtar index 3e9a6f3..b0225f1 100644 --- a/tests/v1alpha2/local/readfile.txtar +++ b/tests/v1alpha2/local/readfile.txtar @@ -4,10 +4,14 @@ exec sh -c 'sed -i "s:WORK:$WORK:g" main/cuegen.cue' exec sh -c 'cd main && find && cuegen .' stdout 'answer_one: "42"' stdout 'answer_main: "43"' +stdout 'answer_config: "44"' -- pkg/one/one.cue -- +//cuegen: process package one +import "cuegen.local/config" answer_one: string @readfile(answer.txt=trim) +answer_config: config.answer_config -- pkg/one/answer.txt -- 42 @@ -28,16 +32,22 @@ cuegen: { } -- main/main.cue -- +//cuegen: process package main import "example.com/pkg/one" objects: [ {answer_one: one.answer_one}, - {answer_main: string @readfile(answer.txt=trim)}, // OK + {answer_main: string @readfile(answer.txt=trim)}, + {answer_config: one.answer_config}, ] -- main/answer.txt -- 43 +-- main/config/answer.txt -- +44 + -- main/config/values.cue -- +//cuegen: process package config -answer_config: string @readfile(answer.txt=trim) // OK +answer_config: string @readfile(answer.txt=trim)