mergeRequirementsFiles reads all files in reqs and appends their contents to dest file.
(reqs []string, dest string)
| 734 | return installRequirementsToTarget(ctx, targetPath, reqs, cmdBuilder) |
| 735 | } |
| 736 | |
| 737 | func resolvePipTargetPaths(ctx *gcp.Context) (string, string) { |
| 738 | targetDir := PipTargetDir() |
| 739 | var targetPath string |
| 740 | if filepath.IsAbs(targetDir) { |
| 741 | targetPath = targetDir |
| 742 | } else { |
| 743 | targetPath = filepath.Join(ctx.ApplicationRoot(), targetDir) |
| 744 | } |
| 745 | return targetDir, targetPath |
| 746 | } |
| 747 | |
| 748 | // mergeRequirementsFiles reads all files in reqs and appends their contents to dest file. |
| 749 | func mergeRequirementsFiles(reqs []string, dest string) error { |
| 750 | destFile, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) |
| 751 | if err != nil { |
| 752 | return fmt.Errorf("failed to open destination file: %w", err) |
| 753 | } |
| 754 | defer destFile.Close() |
| 755 | |
| 756 | for _, req := range reqs { |
| 757 | content, err := os.ReadFile(req) |
| 758 | if err != nil { |
| 759 | return fmt.Errorf("failed to read requirements file %q: %w", req, err) |
| 760 | } |