package app import ( "path/filepath" "strings" ) func (a *App) projectDirFor(p Project) (string, error) { homeDir, err := homeForUnixUser(p.UnixUser) if err != nil { return "", err } tpl := strings.TrimSpace(a.cfg.ProjectRoot) if tpl == "" { tpl = "$HOME/projects/$app" } path := tpl path = strings.ReplaceAll(path, "${HOME}", homeDir) path = strings.ReplaceAll(path, "$HOME", homeDir) path = strings.ReplaceAll(path, "${app}", p.Slug) path = strings.ReplaceAll(path, "$app", p.Slug) if strings.HasPrefix(path, "~/") { path = filepath.Join(homeDir, strings.TrimPrefix(path, "~/")) } if !filepath.IsAbs(path) { path = filepath.Join(homeDir, path) } return filepath.Clean(path), nil }