MCPcopy Create free account
hub / github.com/exercism/cli / Resolve

Function Resolve

config/resolve.go:10–30  ·  view source on GitHub ↗

Resolve cleans up filesystem paths.

(path, home string)

Source from the content-addressed store, hash-verified

8
9// Resolve cleans up filesystem paths.
10func Resolve(path, home string) string {
11 if path == "" {
12 return ""
13 }
14 if strings.HasPrefix(path, "~/") {
15 path = strings.Replace(path, "~/", "", 1)
16 return filepath.Join(home, path)
17 }
18 if filepath.IsAbs(path) {
19 return filepath.Clean(path)
20 }
21 // if using "/dir" on Windows
22 if strings.HasPrefix(path, "/") {
23 return filepath.Join(home, filepath.Clean(path))
24 }
25 cwd, err := os.Getwd()
26 if err != nil {
27 return path
28 }
29 return filepath.Join(cwd, path)
30}

Callers 3

runConfigureFunction · 0.92
TestResolveFunction · 0.85
TestResolveFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestResolveFunction · 0.68
TestResolveFunction · 0.68