mirror of
https://github.com/wahyd4/jabba.git
synced 2026-08-09 04:46:17 +10:00
24 lines
458 B
Go
24 lines
458 B
Go
package command
|
|
|
|
import (
|
|
"github.com/shyiko/jabba/cfg"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
func Which(selector string, home bool) (string, error) {
|
|
aliasValue := GetAlias(selector)
|
|
if aliasValue != "" {
|
|
selector = aliasValue
|
|
}
|
|
ver, err := LsBestMatch(selector)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
path := filepath.Join(cfg.Dir(), "jdk", ver)
|
|
if home && runtime.GOOS == "darwin" {
|
|
path = filepath.Join(path, "Contents", "Home")
|
|
}
|
|
return path, nil
|
|
}
|