MCPcopy Create free account
hub / github.com/driangle/taskmd / resolveProjectTaskDirStandalone

Function resolveProjectTaskDirStandalone

apps/cli/internal/cli/web.go:189–214  ·  view source on GitHub ↗

resolveProjectTaskDirStandalone reads a project's .taskmd.yaml without viper to determine the task directory.

(projectPath string)

Source from the content-addressed store, hash-verified

187// resolveProjectTaskDirStandalone reads a project's .taskmd.yaml without viper
188// to determine the task directory.
189func 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.
217func resolveRelativeTo(path, base string) string {

Callers 1

buildResolveProjectFunction · 0.85

Calls 1

resolveRelativeToFunction · 0.85

Tested by

no test coverage detected