github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/web/web.go (about) 1 package web 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 "runtime" 8 ) 9 10 func StaticPath() (string, error) { 11 _, file, _, ok := runtime.Caller(0) 12 if !ok { 13 return "", fmt.Errorf("Could not locate path to Tilt web static files") 14 } 15 16 // Double-check that the directory exists on disk and at least contains package.json 17 dir := filepath.Dir(file) 18 _, err := os.Stat(filepath.Join(dir, "package.json")) 19 if err != nil { 20 if os.IsNotExist(err) { 21 return "", fmt.Errorf("Could not find Tilt web static files at path: %s", dir) 22 } 23 return "", fmt.Errorf("Could not find Tilt web static files: %v", err) 24 } 25 26 return dir, nil 27 }