Skip to content

Commit

Permalink
fix: only update Casks on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Nov 23, 2024
1 parent 7c791c8 commit ce0c1d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v3.3.1 (2024-11-22)

- Only upgrade Casks on macOS since they aren't supported on Linux

## v3.3.0 (2024-08-22)

- Adds support for Go `1.22` and `1.23`
Expand Down
31 changes: 17 additions & 14 deletions src/brew/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"os"
"os/exec"
"runtime"
"strings"

"github.com/Justintime50/alchemist/v3/src/general"
Expand Down Expand Up @@ -40,20 +41,22 @@ func Update(greedy bool) {
os.Exit(1)
}

fmt.Println("Alchemist is upgrading brew casks...")
upgradeCaskCommand := []string{"upgrade", "--cask"}
if greedy {
upgradeCaskCommand = []string{"upgrade", "--cask", "--greedy"}
}
upgradeCasks, upgradeCasksErr := general.RunCommand(exec.Command, "brew", upgradeCaskCommand)
// Skip if no errors or if the cask cannot be updated due to having a manual installer
if upgradeCasks != nil || strings.Contains(fmt.Sprint(upgradeCasksErr), "installer manual") {
fmt.Println("Alchemist upgraded brew casks!")
log.Printf("brew upgrade --cask: %s", upgradeCasks)
} else {
fmt.Println("Alchemist could not upgrade brew casks, please see logs for details.")
log.Printf("brew upgrade --cask: %s", upgradeCasksErr)
os.Exit(1)
if runtime.GOOS == "darwin" {
fmt.Println("Alchemist is upgrading brew casks...")
upgradeCaskCommand := []string{"upgrade", "--cask"}
if greedy {
upgradeCaskCommand = []string{"upgrade", "--cask", "--greedy"}
}
upgradeCasks, upgradeCasksErr := general.RunCommand(exec.Command, "brew", upgradeCaskCommand)
// Skip if no errors or if the cask cannot be updated due to having a manual installer
if upgradeCasks != nil || strings.Contains(fmt.Sprint(upgradeCasksErr), "installer manual") {
fmt.Println("Alchemist upgraded brew casks!")
log.Printf("brew upgrade --cask: %s", upgradeCasks)
} else {
fmt.Println("Alchemist could not upgrade brew casks, please see logs for details.")
log.Printf("brew upgrade --cask: %s", upgradeCasksErr)
os.Exit(1)
}
}

fmt.Println("Alchemist is cleaning up brew...")
Expand Down

0 comments on commit ce0c1d5

Please sign in to comment.