diff --git a/pkg/commands/install.go b/pkg/commands/install.go index d43ea0f..433bf78 100644 --- a/pkg/commands/install.go +++ b/pkg/commands/install.go @@ -22,9 +22,7 @@ func install(ctx *cli.Context) error { } for _, repo := range dependencies.Slice() { - if config.HasDependency(repo) { - alreadyInstalled(repo) - } else if err = installDependency(&config, paths, repo, false); err != nil { + if err = installDependency(&config, paths, repo, false); err != nil { return err } } @@ -38,16 +36,15 @@ func installAllDependencies(config *utility.PpmConfig, paths utility.Paths) erro return err } } - utility.PrintDone() return nil } func installDependency(config *utility.PpmConfig, paths utility.Paths, dependency string, isSubDependency bool) error { dependency, version := utility.GetVersionOrNot(dependency) if !isSubDependency { - fmt.Printf("\rinstalling %s\n", color.YellowString(utility.GetPluginName(dependency))) + fmt.Printf("\rinstalling %s\n", color.YellowString(utility.GetPluginIdentifier(dependency))) } else { - fmt.Printf("\t -> installing %s\n", color.YellowString(utility.GetPluginName(dependency))) + fmt.Printf("\t -> installing %s\n", color.YellowString(utility.GetPluginIdentifier(dependency))) } loadAnim := utility.StartLoading() @@ -57,7 +54,6 @@ func installDependency(config *utility.PpmConfig, paths utility.Paths, dependenc if err != nil { if err.Error() == "repository already exists" { alreadyInstalled(dependency) - return nil } else { installError(dependency) return err diff --git a/pkg/commands/uninstall.go b/pkg/commands/uninstall.go index da08438..0f9a045 100644 --- a/pkg/commands/uninstall.go +++ b/pkg/commands/uninstall.go @@ -54,7 +54,7 @@ func uninstallAllDependencies(config *utility.PpmConfig, paths utility.Paths, ha } func uninstallDependency(config *utility.PpmConfig, paths utility.Paths, dependency string, isSubDependency bool) error { - dep := utility.GetPluginName(dependency) + dep := utility.GetPluginIdentifier(dependency) if !isSubDependency { fmt.Println("\runinstalling", color.YellowString(dep)) } else { @@ -73,7 +73,8 @@ func uninstallDependency(config *utility.PpmConfig, paths utility.Paths, depende } // path: root/addons/dependency - err = os.RemoveAll(path.Join(paths.Addons, dep)) + fmt.Println(path.Join(paths.Addons, utility.GetPluginName(dep))) + err = os.RemoveAll(path.Join(paths.Addons, utility.GetPluginName(dep))) loadAnim.Stop() if err != nil { return err diff --git a/pkg/utility/ppmconfig.go b/pkg/utility/ppmconfig.go index a23bb3e..9133acc 100644 --- a/pkg/utility/ppmconfig.go +++ b/pkg/utility/ppmconfig.go @@ -40,7 +40,7 @@ func (ppm *PpmConfig) RemoveAllDependencies() { // remove an item safely from the Dependencies property by its name func (ppm *PpmConfig) RemoveSubDependency(dependency string) { - dependency = GetPluginName(dependency) + dependency = GetPluginIdentifier(dependency) ppm.SubDependencies = Filter(ppm.SubDependencies, func(item string, _ int) bool { return item != dependency }) @@ -49,7 +49,7 @@ func (ppm *PpmConfig) RemoveSubDependency(dependency string) { // remove an item safely from the sub-dependencies property by its name func (ppm *PpmConfig) RemoveDependency(dependency string) { - dependency = GetPluginName(dependency) + dependency = GetPluginIdentifier(dependency) ppm.Dependencies = Filter(ppm.Dependencies, func(item string, _ int) bool { return item != dependency }) diff --git a/pkg/utility/utility.go b/pkg/utility/utility.go index 96b7bb9..ca4df27 100644 --- a/pkg/utility/utility.go +++ b/pkg/utility/utility.go @@ -77,7 +77,7 @@ func PrintDone() { fmt.Print(color.GreenString("\rdone\n")) } -func GetPluginName(name string) string { +func GetPluginIdentifier(name string) string { if strings.HasPrefix(name, "https://") { urlParts := strings.Split(name, "/") return urlParts[len(urlParts)-1] @@ -86,6 +86,15 @@ func GetPluginName(name string) string { } } +func GetPluginName(name string) string { + s := GetPluginIdentifier(name) + if strings.Contains(s, "/") { + return strings.Split(s, "/")[1] + } else { + return s + } +} + func GetPathsAndConfig() (Paths, PpmConfig, error) { paths, err := CreatePathsFromCwd() if err != nil {