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)
| 47 | |
| 48 | // WriteBuildScript writes the build steps to a script to be run on each file change in dev mode. |
| 49 | func 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 | } |