diff --git a/scribe/formatted_map.go b/scribe/formatted_map.go index 5012b752..d716f668 100644 --- a/scribe/formatted_map.go +++ b/scribe/formatted_map.go @@ -58,9 +58,17 @@ func NewFormattedMapFromEnvironment(environment map[string]string) FormattedMap case parts[1] == "override" || parts[1] == "default": envMap[parts[0]] = value case parts[1] == "prepend": - envMap[parts[0]] = strings.Join([]string{value, "$" + parts[0]}, environment[parts[0]+".delim"]) + if existingValue, ok := envMap[parts[0]]; ok { + envMap[parts[0]] = strings.Join([]string{value, existingValue.(string)}, environment[parts[0]+".delim"]) + } else { + envMap[parts[0]] = strings.Join([]string{value, "$" + parts[0]}, environment[parts[0]+".delim"]) + } case parts[1] == "append": - envMap[parts[0]] = strings.Join([]string{"$" + parts[0], value}, environment[parts[0]+".delim"]) + if existingValue, ok := envMap[parts[0]]; ok { + envMap[parts[0]] = strings.Join([]string{existingValue.(string), value}, environment[parts[0]+".delim"]) + } else { + envMap[parts[0]] = strings.Join([]string{"$" + parts[0], value}, environment[parts[0]+".delim"]) + } } } diff --git a/scribe/formatted_map_test.go b/scribe/formatted_map_test.go index bee4db11..89daa32a 100644 --- a/scribe/formatted_map_test.go +++ b/scribe/formatted_map_test.go @@ -33,11 +33,15 @@ func testFormattedMap(t *testing.T, context spec.G, it spec.S) { "PREPEND.delim": ":", "APPEND.append": "some-value", "APPEND.delim": ":", + "BOTH.append": "appended-value", + "BOTH.delim": ":", + "BOTH.prepend": "prepended-value", })).To(Equal(scribe.FormattedMap{ "OVERRIDE": "some-value", "DEFAULT": "some-value", "PREPEND": "some-value:$PREPEND", "APPEND": "$APPEND:some-value", + "BOTH": "prepended-value:$BOTH:appended-value", })) }) })