Skip to content

Commit e6d24e9

Browse files
ForestEckhardtryanmoran
authored andcommitted
Moves the default tag next to the type name
1 parent 6e69ab6 commit e6d24e9

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

scribe/emitter.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,29 @@ func (e Emitter) LaunchProcesses(processes []packit.Process, processEnvs ...map[
9494
)
9595

9696
for _, process := range processes {
97-
if len(process.Type) > typePadding {
98-
typePadding = len([]byte(process.Type))
97+
pType := process.Type
98+
if process.Default {
99+
pType += " " + "(default)"
100+
}
101+
102+
if len(pType) > typePadding {
103+
typePadding = len(pType)
99104
}
100105
}
101106

102107
for _, process := range processes {
103-
pad := typePadding + len(process.Command) - len(process.Type)
104-
p := fmt.Sprintf("%s: %*s", process.Type, pad, process.Command)
108+
pType := process.Type
109+
if process.Default {
110+
pType += " " + "(default)"
111+
}
112+
113+
pad := typePadding + len(process.Command) - len(pType)
114+
p := fmt.Sprintf("%s: %*s", pType, pad, process.Command)
105115

106116
if process.Args != nil {
107117
p += " " + strings.Join(process.Args, " ")
108118
}
109119

110-
if process.Default {
111-
p += " " + "(default)"
112-
}
113-
114120
e.Subprocess(p)
115121

116122
// This ensures that the process environment variable is always the same no

scribe/emitter_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func testEmitter(t *testing.T, context spec.G, it spec.S) {
251251
Expect(buffer.String()).To(ContainLines(
252252
" Assigning launch processes:",
253253
" some-type: some-command",
254-
" web: web-command (default)",
254+
" web (default): web-command",
255255
" some-other-type: some-other-command some args",
256256
"",
257257
))
@@ -281,7 +281,7 @@ func testEmitter(t *testing.T, context spec.G, it spec.S) {
281281
Expect(buffer.String()).To(ContainLines(
282282
" Assigning launch processes:",
283283
" some-type: some-command",
284-
" web: web-command (default)",
284+
" web (default): web-command",
285285
` ANOTHER_WEB_VAR -> "another-env"`,
286286
` WEB_VAR -> "some-env"`,
287287
" some-other-type: some-other-command some args",

0 commit comments

Comments
 (0)