@@ -13,26 +13,35 @@ import (
1313var upgradeCmd = & cobra.Command {
1414 Use : "upgrade" ,
1515 Aliases : []string {"update" },
16- Short : "Installs the latest version of the CLI. " ,
16+ Short : "Install the latest version of the CLI" ,
1717 Run : func (cmd * cobra.Command , args []string ) {
1818 info := version .FromContext (cmd .Context ())
1919 if ! info .IsOutdated {
2020 fmt .Println ("Boot.dev CLI is already up to date." )
2121 return
2222 }
23- // install the latest version
23+
24+ fmt .Println ("Upgrading Boot.dev CLI..." )
25+
2426 command := exec .Command ("go" , "install" , "github.com/bootdotdev/bootdev@latest" )
25- _ , err := command .Output ()
27+ command .Stdout = os .Stdout
28+ command .Stderr = os .Stderr
29+ err := command .Run ()
2630 cobra .CheckErr (err )
2731
28- // Get the new version info
32+ // Get new version info
2933 command = exec .Command ("bootdev" , "--version" )
30- b , err := command .Output ()
34+ versionBytes , err := command .Output ()
3135 cobra .CheckErr (err )
36+
3237 re := regexp .MustCompile (`v\d+\.\d+\.\d+` )
33- version := re .FindString (string (b ))
34- fmt .Printf ("Successfully upgraded to %s!\n " , version )
35- os .Exit (0 )
38+ newVersion := re .FindString (string (versionBytes ))
39+ if newVersion == "" {
40+ newVersion = "latest"
41+ }
42+
43+ fmt .Printf ("Successfully upgraded to %s!\n " , newVersion )
44+ os .Exit (0 ) // in case old version is still running
3645 },
3746}
3847
0 commit comments