(ignoreFile, content string)
| 841 | } |
| 842 | |
| 843 | func appendToIgnoreFile(ignoreFile, content string) error { |
| 844 | // Check if ignoreFile exists |
| 845 | _, err := os.Stat(ignoreFile) |
| 846 | if os.IsNotExist(err) { |
| 847 | _ = fsutil.WriteToFile([]byte(content), ignoreFile) |
| 848 | } else { |
| 849 | fileContent, err := os.ReadFile(ignoreFile) |
| 850 | if err != nil { |
| 851 | return errors.Errorf("Error reading file %s: %v", ignoreFile, err) |
| 852 | } |
| 853 | |
| 854 | // append only if not found in file content |
| 855 | if !strings.Contains(string(fileContent), content) { |
| 856 | file, err := os.OpenFile(ignoreFile, os.O_APPEND|os.O_WRONLY, 0600) |
| 857 | if err != nil { |
| 858 | return errors.Errorf("Error writing file %s: %v", ignoreFile, err) |
| 859 | } |
| 860 | |
| 861 | defer file.Close() |
| 862 | if _, err = file.WriteString(content); err != nil { |
| 863 | return errors.Errorf("Error writing file %s: %v", ignoreFile, err) |
| 864 | } |
| 865 | } |
| 866 | } |
| 867 | return nil |
| 868 | } |
| 869 | |
| 870 | func getProjectName() (string, string, error) { |
| 871 | projectName := "" |
no test coverage detected