Skip to content

Commit 163b7bb

Browse files
refactor: streamline installation feedback and enhance tool path resolution - Simplify installation status reporting for runtimes and tools by removing redundant checks - Improve handling of relative binary paths in tool installation checks
1 parent 4f19cde commit 163b7bb

2 files changed

Lines changed: 19 additions & 33 deletions

File tree

cmd/install.go

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,18 @@ var installCmd = &cobra.Command{
217217
var hasFailures bool
218218
for name, runtime := range cfg.Config.Runtimes() {
219219
if !cfg.Config.IsRuntimeInstalled(name, runtime) {
220-
if cfg.Config.IsRuntimeInstalled(name, runtime) {
221-
green.Printf(" ✓ Runtime: %s v%s\n", name, runtime.Version)
222-
} else {
223-
color.Yellow(" ⚠️ Runtime: %s v%s (installation failed)", name, runtime.Version)
224-
hasFailures = true
225-
}
220+
color.Yellow(" ⚠️ Runtime: %s v%s (installation failed)", name, runtime.Version)
221+
hasFailures = true
222+
} else {
223+
green.Printf(" ✓ Runtime: %s v%s\n", name, runtime.Version)
226224
}
227225
}
228226
for name, tool := range cfg.Config.Tools() {
229227
if !cfg.Config.IsToolInstalled(name, tool) {
230-
if cfg.Config.IsToolInstalled(name, tool) {
231-
green.Printf(" ✓ Tool: %s v%s\n", name, tool.Version)
232-
} else {
233-
color.Yellow(" ⚠️ Tool: %s v%s (installation failed)", name, tool.Version)
234-
hasFailures = true
235-
}
228+
color.Yellow(" ⚠️ Tool: %s v%s (installation failed)", name, tool.Version)
229+
hasFailures = true
230+
} else {
231+
green.Printf(" ✓ Tool: %s v%s\n", name, tool.Version)
236232
}
237233
}
238234
fmt.Println()
@@ -247,24 +243,3 @@ var installCmd = &cobra.Command{
247243
}
248244
},
249245
}
250-
251-
func installRuntimes(config *cfg.ConfigType) {
252-
err := cfg.InstallRuntimes(config)
253-
if err != nil {
254-
logger.Error("Failed to install runtimes", logrus.Fields{
255-
"error": err.Error(),
256-
})
257-
log.Fatal(err)
258-
}
259-
}
260-
261-
func installTools(config *cfg.ConfigType, registry string) {
262-
// Use the new tools-installer instead of manual installation
263-
err := cfg.InstallTools(config, registry)
264-
if err != nil {
265-
logger.Error("Failed to install tools", logrus.Fields{
266-
"error": err.Error(),
267-
})
268-
log.Fatal(err)
269-
}
270-
}

config/config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,21 @@ func (c *ConfigType) IsToolInstalled(name string, tool *plugins.ToolInfo) bool {
209209

210210
// Check if at least one binary exists
211211
for _, binaryPath := range tool.Binaries {
212+
// If the path is relative, join it with the installation directory
213+
if !filepath.IsAbs(binaryPath) {
214+
binaryPath = filepath.Join(tool.InstallDir, binaryPath)
215+
}
216+
217+
// Try both with and without .exe
212218
_, err := os.Stat(binaryPath)
213219
if err == nil {
214220
return true
215221
}
222+
223+
_, err = os.Stat(binaryPath + ".exe")
224+
if err == nil {
225+
return true
226+
}
216227
}
217228

218229
return false

0 commit comments

Comments
 (0)