MCPcopy Index your code
hub / github.com/jetify-com/devbox / WriteScriptFile

Function WriteScriptFile

internal/shellgen/scripts.go:101–114  ·  view source on GitHub ↗
(devbox devboxer, name, body string)

Source from the content-addressed store, hash-verified

99}
100
101func WriteScriptFile(devbox devboxer, name, body string) (err error) {
102 script, err := createScriptFile(devbox, name)
103 if err != nil {
104 return errors.WithStack(err)
105 }
106 defer script.Close() // best effort: close file
107
108 if featureflag.ScriptExitOnError.Enabled() {
109 // NOTE: Devbox scripts run using `sh` for consistency.
110 body = fmt.Sprintf("set -e\n\n%s", body)
111 }
112 _, err = script.WriteString(body)
113 return errors.WithStack(err)
114}
115
116func createScriptFile(devbox devboxer, name string) (script *os.File, err error) {
117 script, err = os.Create(ScriptPath(devbox.ProjectDir(), name))

Callers 2

RunScriptMethod · 0.92
WriteScriptsToFilesFunction · 0.85

Calls 2

createScriptFileFunction · 0.85
EnabledMethod · 0.80

Tested by

no test coverage detected