Skip to content

Commit

Permalink
fix: fix user input when installing bug
Browse files Browse the repository at this point in the history
Fixed a bug in the installation process that was causing packages to not be installed properly. Now, packages are being installed correctly.
  • Loading branch information
banahaker committed Mar 31, 2024
1 parent caefab6 commit 613f37f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
30 changes: 14 additions & 16 deletions commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,32 @@ func Install(c *cli.Context) {
log.Fatal(err)
}

if name := c.String("name"); name != "" {
// finding the name in file list
packageName := c.String("name")
if packageName != "" {
for _, file := range config.Files {
if file.Name == name {
fmt.Println("Installing... " + name)
err := module.InstallPackageWithFilePath(home + "/.ui/cache/" + filepath.Base(file.URL))
if err != nil {
log.Fatal(err)
}
if file.Name == packageName {
installPackage(home, file.URL)
return
}
}
log.Fatal("Package not found")
return
}

for _, file := range config.Files {
fmt.Println(file.Name + " Downloading... " + " " + file.URL)
fmt.Println(file.Name + " Downloading... " + file.URL)
module.DownloadFileToCache(file.URL)
}

fmt.Println("Download complete!")

for _, file := range config.Files {
fmt.Println("Installing... " + file.Name)
err := module.InstallPackageWithFilePath(home + "/.ui/cache/" + filepath.Base(file.URL))
if err != nil {
log.Fatal(err)
}
installPackage(home, file.URL)
}
}

func installPackage(home, filePath string) {
fileName := filepath.Base(filePath)
err := module.InstallPackageWithFilePath(home + "/.ui/cache/" + fileName)
if err != nil {
log.Fatal(err)
}
}
8 changes: 7 additions & 1 deletion module/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ func InstallPackageWithFilePath(filePath string) error {
return nil
}

cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
err := cmd.Run()

if err != nil {
return err
}

return nil
}

0 comments on commit 613f37f

Please sign in to comment.