Skip to content

Commit

Permalink
polish: typos, reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
Frankie Gallina-Jones authored and ForestEckhardt committed Oct 20, 2021
1 parent cc8eb1b commit 4f2328c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
18 changes: 9 additions & 9 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ func Build(
return func(context packit.BuildContext) (packit.BuildResult, error) {
logs.Title("%s %s", context.BuildpackInfo.Name, context.BuildpackInfo.Version)

shouldReload, err := checkLiveReloadEnabled()
if err != nil {
return packit.BuildResult{}, err
}

if shouldReload && context.Stack == TinyStackName {
return packit.BuildResult{}, fmt.Errorf("cannot enable live reload on stack '%s': stack does not support watchexec", context.Stack)
}

targetsLayer, err := context.Layers.Get(TargetsLayerName)
if err != nil {
return packit.BuildResult{}, err
Expand Down Expand Up @@ -112,15 +121,6 @@ func Build(
},
}

shouldReload, err := checkLiveReloadEnabled()
if err != nil {
return packit.BuildResult{}, err
}

if shouldReload && context.Stack == TinyStackName {
return packit.BuildResult{}, fmt.Errorf("cannot enable live reload on stack '%s': stack does not support watchexec", context.Stack)
}

if shouldReload {
processes = []packit.Process{
{
Expand Down
46 changes: 23 additions & 23 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,28 +300,6 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
}))
})

context("and BP_LIVE_RELOAD_ENABLED=true in the build environment", func() {
it.Before(func() {
os.Setenv("BP_LIVE_RELOAD_ENABLED", "true")
})

it.After(func() {
os.Unsetenv("BP_LIVE_RELOAD_ENABLED")
})
it("fails the build and logs that watchexec is not supported on Tiny", func() {
_, err := build(packit.BuildContext{
WorkingDir: workingDir,
CNBPath: cnbDir,
Stack: "io.paketo.stacks.tiny",
BuildpackInfo: packit.BuildpackInfo{
Name: "Some Buildpack",
Version: "some-version",
},
Layers: packit.Layers{Path: layersDir},
})
Expect(err).To(MatchError(ContainSubstring("cannot enable live reload on stack 'io.paketo.stacks.tiny': stack does not support watchexec")))
})
})
})

context("when the targets were previously built", func() {
Expand Down Expand Up @@ -483,7 +461,7 @@ launch = true
})
})

context("when the checksum cannot be calculatred", func() {
context("when the checksum cannot be calculated", func() {
it.Before(func() {
checksumCalculator.SumCall.Returns.Error = errors.New("failed to calculate checksum")
})
Expand Down Expand Up @@ -564,5 +542,27 @@ launch = true
Expect(err).To(MatchError(ContainSubstring("failed to parse BP_LIVE_RELOAD_ENABLED value not-a-bool")))
})
})
context("when stack is tiny and BP_LIVE_RELOAD_ENABLED=true in the build environment", func() {
it.Before(func() {
os.Setenv("BP_LIVE_RELOAD_ENABLED", "true")
})

it.After(func() {
os.Unsetenv("BP_LIVE_RELOAD_ENABLED")
})
it("fails the build and logs that watchexec is not supported on Tiny", func() {
_, err := build(packit.BuildContext{
WorkingDir: workingDir,
CNBPath: cnbDir,
Stack: "io.paketo.stacks.tiny",
BuildpackInfo: packit.BuildpackInfo{
Name: "Some Buildpack",
Version: "some-version",
},
Layers: packit.Layers{Path: layersDir},
})
Expect(err).To(MatchError(ContainSubstring("cannot enable live reload on stack 'io.paketo.stacks.tiny': stack does not support watchexec")))
})
})
})
}
1 change: 0 additions & 1 deletion detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
context("BP_LIVE_RELOAD_ENABLED=true and the stack is tiny", func() {
it.Before(func() {
os.Setenv("BP_LIVE_RELOAD_ENABLED", "true")

})

it.After(func() {
Expand Down

0 comments on commit 4f2328c

Please sign in to comment.