libreload

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 1 Imported by: 14

README

Paketo libreload

This library exists to easily support live reloadable processes for Paketo-style buildpacks built using packit v2.

Detect

Use ShouldEnableLiveReload to decide when to require the necessary dependency.

if shouldEnableReload, err := reload.ShouldEnableLiveReload(); err != nil {
    return packit.DetectResult{}, err
} else if shouldEnableReload {
    requirements = append(requirements, <require your preferred reload implementation such as watchexec>)
}

Build

Use TransformReloadableProcesses to transform the non-reloadable process into a reloadable and non-reloadable process.

if shouldEnableReload, err := reload.ShouldEnableLiveReload(); err != nil {
    return packit.BuildResult{}, err
} else if shouldEnableReload {
    nonReloadableProcess, reloadableProcess := reload.TransformReloadableProcesses(originalProcess, libreload.ReloadableProcessSpec{
        WatchPaths: []string{...},
        Shell: "none",
    })
    processes = append(processes, nonReloadableProcess, reloadableProcess)
} else {
    processes = append(processes, originalProcess)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LiveReloadEnabledEnvVar = "BP_LIVE_RELOAD_ENABLED"

Functions

This section is empty.

Types

type ReloadableProcessSpec

type ReloadableProcessSpec struct {
	WatchPaths     []string
	IgnorePaths    []string
	Shell          string
	VerbosityLevel int
}

type Reloader

type Reloader interface {
	ShouldEnableLiveReload() (bool, error)
	TransformReloadableProcesses(originalProcess packit.Process, spec ReloadableProcessSpec) (nonReloadable packit.Process, reloadable packit.Process)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL