Skip to content

Commit

Permalink
install: enhance code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Tch1b0 committed Jul 22, 2022
1 parent 525b301 commit 3099d93
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pkg/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ func install(ctx *cli.Context) error {
installAllDependencies(&config, paths)
}

for i := 0; i < dependencies.Len(); i++ {
repo := dependencies.Get(i)

for _, repo := range dependencies.Slice() {
if config.HasDependency(repo) {
alreadyInstalled(repo)
} else if err = installDependency(&config, paths, repo, false); err != nil {
Expand Down Expand Up @@ -56,8 +54,6 @@ func installDependency(config *utility.PpmConfig, paths utility.Paths, dependenc
err := utility.Clone(paths.Addons, dependency, version)
loadAnim.Stop()

var addDependency bool

if err != nil {
if err.Error() == "repository already exists" {
alreadyInstalled(dependency)
Expand All @@ -68,11 +64,12 @@ func installDependency(config *utility.PpmConfig, paths utility.Paths, dependenc
}
}

addDependency = (!isSubDependency && !config.HasDependency(dependency)) || (isSubDependency && !config.HasSubDependency(dependency))
shouldAddDep := (!isSubDependency && !config.HasDependency(dependency)) ||
(isSubDependency && !config.HasSubDependency(dependency))

if addDependency && isSubDependency {
if shouldAddDep && isSubDependency {
config.AddSubDependency(dependency)
} else if addDependency {
} else if shouldAddDep {
config.AddDependency(dependency)
}

Expand Down

0 comments on commit 3099d93

Please sign in to comment.