Skip to content

Commit d0206d6

Browse files
committed
when merging ENV force use for KEY=VAL syntax
1 parent 5c43152 commit d0206d6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

dfpp.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,13 @@ func (pp *Dfpp) Merge(merge bool, docs []string, include, exclude map[string]boo
167167
details := strings.TrimPrefix(line, fields[0]+" ")
168168

169169
if sref, ok := ops[op]; merge && ok {
170-
if op == "ENV" || op == "LABEL" {
170+
if op == "ENV" {
171+
if !strings.Contains(details, "=") {
172+
fields := strings.Fields(details)
173+
details = strings.Join(fields, "=")
174+
}
175+
*sref += " \\\n" + strings.Repeat(" ", len(op)+1) + details
176+
} else if op == "LABEL" {
171177
*sref += " \\\n" + strings.Repeat(" ", len(op)+1) + details
172178
} else if op == "RUN" {
173179
*sref += " && \\\n " + details
@@ -184,6 +190,12 @@ func (pp *Dfpp) Merge(merge bool, docs []string, include, exclude map[string]boo
184190
result = append(result, &dup)
185191
}
186192
} else {
193+
if op == "ENV" && !strings.Contains(line, "=") {
194+
line = strings.TrimPrefix(line, "ENV")
195+
line = strings.TrimSpace(line)
196+
fields := strings.Fields(line)
197+
line = fmt.Sprintf("ENV %s", strings.Join(fields, "="))
198+
}
187199
dup := string(line)
188200
result = append(result, &dup)
189201
ops[op] = result[len(result)-1]

0 commit comments

Comments
 (0)