Skip to content

Commit a444384

Browse files
committed
fix: extendedVars wth "./" prefix
1 parent f79e1cc commit a444384

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

docs/helpers/extendedEnv.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,35 @@ func GetRogueEnvs() {
9292

9393
// find current vars
9494
currentVars := make(map[string]Variable)
95+
totalLines := len(lines)
96+
fmt.Printf("Processing %d lines...\n", totalLines)
97+
9598
for _, l := range lines {
99+
100+
if l == "" {
101+
continue
102+
}
103+
96104
fmt.Printf("Parsing %s\n", l)
97-
r := strings.SplitN(l, ":\t", 2)
98-
if len(r) != 2 || r[0] == "" || r[1] == "" {
105+
r := strings.SplitN(l, ":", 3)
106+
if len(r) != 3 || r[0] == "" || r[2] == "" {
99107
continue
100108
}
101109

102-
res := re.FindAllSubmatch([]byte(r[1]), -1)
110+
// Remove ./ prefix from path if it exists
111+
path := strings.TrimPrefix(r[0], "./")
112+
path = path + ":" + r[1] // Reconstruct path:line
113+
content := r[2]
114+
115+
res := re.FindAllSubmatch([]byte(content), -1)
103116
if len(res) < 1 {
104-
fmt.Printf("Error envvar not matching pattern: %s", r[1])
117+
fmt.Printf(" No envvar found in content: %s\n", content)
105118
continue
106119
}
107120

108121
for _, m := range res {
109-
path := r[0]
110122
name := strings.Trim(string(m[1]), "\"")
123+
fmt.Printf(" Found envvar: %s at %s\n", name, path)
111124
currentVars[path+name] = Variable{
112125
RawName: name,
113126
Path: path,
@@ -117,6 +130,7 @@ func GetRogueEnvs() {
117130
}
118131
}
119132

133+
fmt.Printf("Found %d current variables\n", len(currentVars))
120134
// adjust existing vars
121135
for i, v := range vars.Variables {
122136
_, ok := currentVars[v.Path+v.RawName]

0 commit comments

Comments
 (0)