diff --git a/internal/cmd/install.go b/internal/cmd/install.go index 9d47ec2..defaa1c 100644 --- a/internal/cmd/install.go +++ b/internal/cmd/install.go @@ -1,11 +1,13 @@ package cmd import ( + "bufio" "errors" "fmt" "os" "os/exec" "path/filepath" + "runtime" "github.com/AlecAivazis/survey/v2" "github.com/anoriqq/qpm/internal/config" @@ -76,7 +78,7 @@ func getPkgName(args []string) (string, error) { } func getInstallScriptPaht(scriptDir, pkgName string) (string, error) { - installScriptPath, err := filepath.Abs(fmt.Sprintf("%s/%s/install.sh", scriptDir, pkgName)) + installScriptPath, err := filepath.Abs(fmt.Sprintf("%s/%s/latest.sh", scriptDir, pkgName)) if err != nil { return "", err } @@ -90,12 +92,19 @@ func execInstallScript(installScriptPath string) error { return fmt.Errorf("install script not found: %s", installScriptPath) } - o, err := exec.Command("/bin/sh", installScriptPath).Output() + c := exec.Command("/bin/sh", installScriptPath, "install", runtime.GOOS, runtime.GOARCH) + + stdout, err := c.StdoutPipe() if err != nil { return err } - fmt.Println(string(o)) + c.Start() + + scanner := bufio.NewScanner(stdout) + for scanner.Scan() { + fmt.Println(scanner.Text()) + } - return nil + return c.Wait() } diff --git a/internal/config/config.go b/internal/config/config.go index 4ad7992..2919d46 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -87,7 +87,7 @@ func HasScriptDir() bool { func SetScriptDir(scriptDir string) error { viper.Set("ScriptDir", scriptDir) - err := viper.WriteConfig() + err := viper.WriteConfig() if err != nil { return err } diff --git a/main.go b/main.go index 32699ed..2192e2c 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/anoriqq/qpm/internal/cmd" @@ -10,7 +9,6 @@ import ( func main() { err := cmd.Execute() if err != nil { - fmt.Printf("%+v\n", err) os.Exit(1) } }