Skip to content

Commit

Permalink
fix: invalid boolean comparsions w/ maps
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Dec 5, 2024
1 parent f6c1895 commit 9339ee0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func Update(cmd *cobra.Command, args []string) {
}

initConfiguration := drv.UpdaterInitConfiguration{}.New()
_, empty := os.LookupEnv("CI")
initConfiguration.Ci = !empty
_, exists := os.LookupEnv("CI")
initConfiguration.Ci = exists
initConfiguration.DryRun = dryRun
initConfiguration.Verbose = verboseRun

Expand Down
19 changes: 10 additions & 9 deletions drv/brew.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,32 @@ type BrewUpdater struct {

func (up BrewUpdater) New(config UpdaterInitConfiguration) (BrewUpdater, error) {
up.Environment = config.Environment
brewPrefix, empty := up.Environment["HOMEBREW_PREFIX"]
if empty || brewPrefix == "" {

brewPrefix, exists := up.Environment["HOMEBREW_PREFIX"]
if !exists || brewPrefix == "" {
up.BrewPrefix = "/home/linuxbrew/.linuxbrew"
} else {
up.BrewPrefix = brewPrefix
}
brewRepo, empty := up.Environment["HOMEBREW_REPOSITORY"]
if empty || brewRepo == "" {
brewRepo, exists := up.Environment["HOMEBREW_REPOSITORY"]
if !exists || brewRepo == "" {
up.BrewRepo = fmt.Sprintf("%s/Homebrew", up.BrewPrefix)
} else {
up.BrewRepo = brewRepo
}
brewCellar, empty := up.Environment["HOMEBREW_CELLAR"]
if empty || brewCellar == "" {
brewCellar, exists := up.Environment["HOMEBREW_CELLAR"]
if !exists || brewCellar == "" {
up.BrewCellar = fmt.Sprintf("%s/Cellar", up.BrewPrefix)
} else {

up.BrewCellar = brewCellar
}
brewPath, empty := up.Environment["HOMEBREW_PATH"]
if empty || brewPath == "" {
brewPath, exists := up.Environment["HOMEBREW_PATH"]
if !exists || brewPath == "" {
up.BrewPath = fmt.Sprintf("%s/bin/brew", up.BrewPrefix)
} else {
up.BrewPath = brewPath
}

up.Config = DriverConfiguration{
Title: "Brew",
Description: "CLI Apps",
Expand Down
4 changes: 2 additions & 2 deletions drv/distrobox.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func (up DistroboxUpdater) New(config UpdaterInitConfiguration) (DistroboxUpdate
up.usersEnabled = false
up.Tracker = nil

binaryPath, empty := config.Environment["UUPD_DISTROBOX_BINARY"]
if empty || binaryPath == "" {
binaryPath, exists := config.Environment["UUPD_DISTROBOX_BINARY"]
if !exists || binaryPath == "" {
up.binaryPath = "/usr/bin/distrobox"
} else {
up.binaryPath = binaryPath
Expand Down
4 changes: 2 additions & 2 deletions drv/flatpak.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (up FlatpakUpdater) New(config UpdaterInitConfiguration) (FlatpakUpdater, e
up.usersEnabled = false
up.Tracker = nil

binaryPath, empty := config.Environment["UUPD_FLATPAK_BINARY"]
if empty || binaryPath == "" {
binaryPath, exists := config.Environment["UUPD_FLATPAK_BINARY"]
if !exists || binaryPath == "" {
up.binaryPath = "/usr/bin/flatpak"
} else {
up.binaryPath = binaryPath
Expand Down
8 changes: 4 additions & 4 deletions drv/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ func (up SystemUpdater) New(config UpdaterInitConfiguration) (SystemUpdater, err
}

up.SystemDriver = SystemDriver{}
bootcBinaryPath, empty := config.Environment["UUPD_BOOTC_BINARY"]
if empty || bootcBinaryPath == "" {
bootcBinaryPath, exists := config.Environment["UUPD_BOOTC_BINARY"]
if !exists || bootcBinaryPath == "" {
up.SystemDriver.bootcBinaryPath = "/usr/bin/bootc"
} else {
up.SystemDriver.bootcBinaryPath = bootcBinaryPath
}
rpmOstreeBinaryPath, empty := config.Environment["UUPD_RPMOSTREE_BINARY"]
if empty || rpmOstreeBinaryPath == "" {
rpmOstreeBinaryPath, exists := config.Environment["UUPD_RPMOSTREE_BINARY"]
if !exists || rpmOstreeBinaryPath == "" {
up.SystemDriver.rpmOstreeBinaryPath = "/usr/bin/rpm-ostree"
} else {
up.SystemDriver.rpmOstreeBinaryPath = rpmOstreeBinaryPath
Expand Down

0 comments on commit 9339ee0

Please sign in to comment.