resolveProjectTaskDirStandalone reads a project's .taskmd.yaml without viper to determine the task directory.
(projectPath string)
| 187 | // resolveProjectTaskDirStandalone reads a project's .taskmd.yaml without viper |
| 188 | // to determine the task directory. |
| 189 | func resolveProjectTaskDirStandalone(projectPath string) (string, error) { |
| 190 | cfgPath := filepath.Join(projectPath, ".taskmd.yaml") |
| 191 | data, err := os.ReadFile(cfgPath) |
| 192 | if err != nil { |
| 193 | if os.IsNotExist(err) { |
| 194 | return projectPath, nil |
| 195 | } |
| 196 | return "", fmt.Errorf("read project config: %w", err) |
| 197 | } |
| 198 | |
| 199 | var cfg struct { |
| 200 | TaskDir string `yaml:"task-dir"` |
| 201 | Dir string `yaml:"dir"` |
| 202 | } |
| 203 | if err := yaml.Unmarshal(data, &cfg); err != nil { |
| 204 | return "", fmt.Errorf("parse project config: %w", err) |
| 205 | } |
| 206 | |
| 207 | if cfg.TaskDir != "" { |
| 208 | return resolveRelativeTo(cfg.TaskDir, projectPath), nil |
| 209 | } |
| 210 | if cfg.Dir != "" { |
| 211 | return resolveRelativeTo(cfg.Dir, projectPath), nil |
| 212 | } |
| 213 | return projectPath, nil |
| 214 | } |
| 215 | |
| 216 | // resolveRelativeTo makes a path absolute relative to a base directory. |
| 217 | func resolveRelativeTo(path, base string) string { |
no test coverage detected