MCPcopy Create free account
hub / github.com/jetify-com/devbox / triggerUpdate

Function triggerUpdate

internal/vercheck/vercheck.go:174–203  ·  view source on GitHub ↗

triggerUpdate runs `devbox version -v` and triggers an update since a new version is available. It parses the output to get the new launcher and devbox versions.

(stdErr io.Writer)

Source from the content-addressed store, hash-verified

172// version is available. It parses the output to get the new launcher and
173// devbox versions.
174func triggerUpdate(stdErr io.Writer) (*updatedVersions, error) {
175 exePath := os.Getenv(envir.LauncherPath)
176 if exePath == "" {
177 ux.Fwarningf(stdErr, "expected LAUNCHER_PATH to be set. Defaulting to \"devbox\".")
178 exePath = "devbox"
179 }
180
181 // TODO savil. Add a --json flag to devbox version and parse the output as JSON
182 cmd := exec.Command(exePath, "version", "-v")
183
184 buf := new(bytes.Buffer)
185 cmd.Stdout = io.MultiWriter(stdErr, buf)
186 cmd.Stderr = stdErr
187 if err := cmd.Run(); err != nil {
188 return nil, errors.WithStack(err)
189 }
190
191 // Parse the output to ascertain the new devbox and launcher versions
192 updated := &updatedVersions{}
193 for _, line := range strings.Split(buf.String(), "\n") {
194 if strings.HasPrefix(line, "Version:") {
195 updated.devboxVersion = strings.TrimSpace(strings.TrimPrefix(line, "Version:"))
196 }
197
198 if strings.HasPrefix(line, "Launcher:") {
199 updated.launcherVersion = strings.TrimSpace(strings.TrimPrefix(line, "Launcher:"))
200 }
201 }
202 return updated, nil
203}
204
205func printSuccessMessage(w io.Writer, toolName, oldVersion, newVersion string) {
206 var msg string

Callers 2

selfUpdateLauncherFunction · 0.85
selfUpdateDevboxFunction · 0.85

Calls 4

FwarningfFunction · 0.92
CommandMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected