writeInitFiles writes files to a directory, returning created paths.
(dir string, files []fileToWrite, quiet bool)
| 670 | |
| 671 | // writeInitFiles writes files to a directory, returning created paths. |
| 672 | func writeInitFiles(dir string, files []fileToWrite, quiet bool) ([]string, error) { |
| 673 | var created []string |
| 674 | |
| 675 | for _, f := range files { |
| 676 | absPath, skipped, err := writeInitFile(dir, f) |
| 677 | if err != nil { |
| 678 | return created, err |
| 679 | } |
| 680 | if skipped { |
| 681 | if !quiet { |
| 682 | fmt.Fprintf(os.Stderr, "Skipped %s (already exists, use --force to overwrite)\n", absPath) |
| 683 | } |
| 684 | continue |
| 685 | } |
| 686 | created = append(created, absPath) |
| 687 | } |
| 688 | |
| 689 | return created, nil |
| 690 | } |
| 691 | |
| 692 | func writeInitFile(targetDir string, f fileToWrite) (absPath string, skipped bool, err error) { |
| 693 | outputPath := filepath.Join(targetDir, f.filename) |
no test coverage detected