WriteTaskFile creates a new task markdown file and returns the file path.
(dir, id string, mapped MappedTask, externalID, sourceName string)
| 12 | |
| 13 | // WriteTaskFile creates a new task markdown file and returns the file path. |
| 14 | func WriteTaskFile(dir, id string, mapped MappedTask, externalID, sourceName string) (string, error) { |
| 15 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 16 | return "", fmt.Errorf("failed to create output directory: %w", err) |
| 17 | } |
| 18 | |
| 19 | s := slug.Slugify(mapped.Title) |
| 20 | filename := fmt.Sprintf("%s-%s.md", id, s) |
| 21 | path := filepath.Join(dir, filename) |
| 22 | |
| 23 | content := renderTaskFile(id, mapped, externalID, sourceName) |
| 24 | |
| 25 | if err := os.WriteFile(path, []byte(content), 0644); err != nil { |
| 26 | return "", fmt.Errorf("failed to write task file: %w", err) |
| 27 | } |
| 28 | |
| 29 | return path, nil |
| 30 | } |
| 31 | |
| 32 | // UpdateSyncedTaskFile updates an existing synced task file. |
| 33 | func UpdateSyncedTaskFile(filePath string, mapped MappedTask) error { |
no test coverage detected