forked from toolshed/abra
feat: update new version in env file
This commit is contained in:
@ -568,3 +568,30 @@ func ReadAbraShCmdNames(abraSh string) ([]string, error) {
|
||||
|
||||
return cmdNames, nil
|
||||
}
|
||||
|
||||
func (a App) WriteRecipeVersion(version string) error {
|
||||
file, err := os.Open(a.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
lines := []string{}
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if !strings.Contains(line, "RECIPE=") && !strings.Contains(line, "TYPE") {
|
||||
lines = append(lines, line)
|
||||
continue
|
||||
}
|
||||
splitted := strings.Split(line, ":")
|
||||
line = fmt.Sprintf("%s:%s", splitted[0], version)
|
||||
lines = append(lines, line)
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return os.WriteFile(a.Path, []byte(strings.Join(lines, "\n")), os.ModePerm)
|
||||
}
|
||||
|
Reference in New Issue
Block a user