MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/buildpacks / WriteBuildScript

Function WriteBuildScript

pkg/devmode/java.go:49–66  ·  view source on GitHub ↗

WriteBuildScript writes the build steps to a script to be run on each file change in dev mode.

(ctx *gcp.Context, layerSrc, dest string, command []string)

Source from the content-addressed store, hash-verified

47
48// WriteBuildScript writes the build steps to a script to be run on each file change in dev mode.
49func WriteBuildScript(ctx *gcp.Context, layerSrc, dest string, command []string) error {
50 var script bytes.Buffer
51 buildScriptTmpl.Execute(&script, map[string]string{
52 "src": layerSrc,
53 "dest": dest,
54 "buildCommand": strings.Join(command, " "),
55 })
56
57 bin := filepath.Join(layerSrc, "bin")
58 if err := ctx.MkdirAll(bin, 0755); err != nil {
59 return err
60 }
61 shPath := filepath.Join(bin, ".devmode_rebuild.sh")
62 if err := ctx.WriteFile(shPath, script.Bytes(), os.FileMode(0744)); err != nil {
63 return err
64 }
65 return nil
66}

Callers 2

BuildFnFunction · 0.92
BuildFnFunction · 0.92

Calls 3

MkdirAllMethod · 0.80
WriteFileMethod · 0.80
BytesMethod · 0.80

Tested by

no test coverage detected