github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/tiltfile/starkit/path.go (about) 1 package starkit 2 3 import ( 4 "path/filepath" 5 6 "go.starlark.net/starlark" 7 ) 8 9 // We want to resolve paths relative to the dir where the currently executing file lives, 10 // not relative to the working directory. 11 func AbsPath(t *starlark.Thread, path string) string { 12 if filepath.IsAbs(path) { 13 return path 14 } 15 return filepath.Join(AbsWorkingDir(t), path) 16 } 17 18 func AbsWorkingDir(t *starlark.Thread) string { 19 return filepath.Dir(CurrentExecPath(t)) 20 } 21 22 // Path to the file that's currently executing 23 func CurrentExecPath(t *starlark.Thread) string { 24 ret := t.Local(execingTiltfileKey) 25 if ret == nil { 26 panic("internal error: currentExecPath must be called from an active starlark thread") 27 } 28 return ret.(string) 29 }