Skip to content

Commit 80194d5

Browse files
ForestEckhardtsophiewigmore
authored andcommitted
Adds function to the emitter that logs launch processes
Signed-off-by: Timothy Hitchener <thitchener@pivotal.io>
1 parent a0e5e3f commit 80194d5

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

scribe/emitter.go

+23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package scribe
22

33
import (
4+
"fmt"
45
"io"
56
"strconv"
7+
"strings"
68
"time"
79

810
"github.com/paketo-buildpacks/packit"
@@ -83,3 +85,24 @@ Entries:
8385

8486
e.Break()
8587
}
88+
89+
func (e Emitter) LaunchProcesses(processes []packit.Process) {
90+
e.Process("Assigning launch processes:")
91+
92+
for _, process := range processes {
93+
p := fmt.Sprintf("%s: %s", process.Type, process.Command)
94+
95+
if process.Args != nil {
96+
p = fmt.Sprintf("%s %s", p, strings.Join(process.Args, " "))
97+
}
98+
99+
// This conditional should be replaced when API 0.6 is supported at which
100+
// point any process can be set as default
101+
if process.Type == "web" {
102+
p = fmt.Sprintf("%s %s", p, "(default)")
103+
}
104+
105+
e.Subprocess(p)
106+
}
107+
e.Break()
108+
}

scribe/emitter_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,31 @@ func testEmitter(t *testing.T, context spec.G, it spec.S) {
189189
})
190190
})
191191
})
192+
193+
context("LaunchProcesses", func() {
194+
it("prints a list of launch processes", func() {
195+
emitter.LaunchProcesses([]packit.Process{
196+
{
197+
Type: "some-type",
198+
Command: "some-command",
199+
},
200+
{
201+
Type: "web",
202+
Command: "web-command",
203+
},
204+
{
205+
Type: "some-other-type",
206+
Command: "some-other-command",
207+
Args: []string{"some", "args"},
208+
},
209+
})
210+
211+
Expect(buffer.String()).To(Equal(` Assigning launch processes:
212+
some-type: some-command
213+
web: web-command (default)
214+
some-other-type: some-other-command some args
215+
216+
`), buffer.String())
217+
})
218+
})
192219
}

0 commit comments

Comments
 (0)