diff --git a/cmd/protobuild/cmd.go b/cmd/protobuild/cmd.go index 3d70fbb..7a20653 100644 --- a/cmd/protobuild/cmd.go +++ b/cmd/protobuild/cmd.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/fs" + "log/slog" "os" "os/exec" "path/filepath" @@ -478,12 +479,23 @@ func Main() *cli.Command { defer recovery.Exit() for _, plg := range globalCfg.Installers { - if !strings.Contains(plg, "@") || force { - if strings.Contains(plg, "@") { - pluginPaths := strings.Split(plg, "@") - plg = strings.Join(pluginPaths[:len(pluginPaths)-1], "@") + "@latest" - } + if !strings.Contains(plg, "@") { + pluginPaths := strings.Split(plg, "@") + plg = strings.Join(pluginPaths[:len(pluginPaths)-1], "@") + "@latest" + } + + plgName := strings.Split(lo.LastOrEmpty(strings.Split(plg, "/")), "@")[0] + path, err := exec.LookPath(plgName) + if err != nil { + slog.Error("command not found", slog.Any("name", plgName)) } + + if err == nil && !force { + slog.Info("command path", slog.Any("path", path)) + continue + } + + slog.Info("install command", slog.Any("name", plg)) assert.Must(shutil.Shell("go", "install", plg).Run()) } return nil diff --git a/internal/shutil/shell.go b/internal/shutil/shell.go index 99dbee7..136f815 100644 --- a/internal/shutil/shell.go +++ b/internal/shutil/shell.go @@ -2,6 +2,7 @@ package shutil import ( "bytes" + "log/slog" "os" "os/exec" "strings" @@ -36,6 +37,7 @@ func GoList() (string, error) { func Shell(args ...string) *exec.Cmd { shell := strings.Join(args, " ") + slog.Info(shell) cmd := exec.Command("/bin/sh", "-c", shell) cmd.Env = os.Environ() cmd.Stdout = os.Stdout