| 690 | } |
| 691 | |
| 692 | func writeInitFile(targetDir string, f fileToWrite) (absPath string, skipped bool, err error) { |
| 693 | outputPath := filepath.Join(targetDir, f.filename) |
| 694 | absPath, err = filepath.Abs(outputPath) |
| 695 | if err != nil { |
| 696 | absPath = outputPath |
| 697 | } |
| 698 | |
| 699 | if !projectInitForce { |
| 700 | if _, err := os.Stat(outputPath); err == nil { |
| 701 | return absPath, true, nil |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | if err := os.WriteFile(outputPath, f.content, 0644); err != nil { |
| 706 | return absPath, false, fmt.Errorf("failed to write %s: %w", f.filename, err) |
| 707 | } |
| 708 | |
| 709 | return absPath, false, nil |
| 710 | } |
| 711 | |
| 712 | // printInitSummary prints the list of created files and next steps. |
| 713 | func printInitSummary(createdPaths []string) { |