chore: various cosmetic changes.

This commit is contained in:
Alexandre Pujol 2023-09-01 19:26:52 +01:00
parent 256d4abde8
commit aea0034fcc
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
16 changed files with 35 additions and 32 deletions

View file

@ -19,7 +19,7 @@ var Builds = []BuildFunc{
var (
regAttachments = regexp.MustCompile(`(profile .* @{exec_path})`)
regFlag = regexp.MustCompile(`flags=\(([^)]+)\)`)
regFlagComplain = regexp.MustCompile(`flags=\(([^)]+)\)`)
regProfileHeader = regexp.MustCompile(` {`)
)
@ -28,7 +28,7 @@ type BuildFunc func(string) string
// Set complain flag on all profiles
func BuildComplain(profile string) string {
flags := []string{}
matches := regFlag.FindStringSubmatch(profile)
matches := regFlagComplain.FindStringSubmatch(profile)
if len(matches) != 0 {
flags = strings.Split(matches[1], ",")
if slices.Contains(flags, "complain") {
@ -39,7 +39,7 @@ func BuildComplain(profile string) string {
strFlags := " flags=(" + strings.Join(flags, ",") + ") {"
// Remove all flags definition, then set manifest' flags
profile = regFlag.ReplaceAllLiteralString(profile, "")
profile = regFlagComplain.ReplaceAllLiteralString(profile, "")
return regProfileHeader.ReplaceAllLiteralString(profile, strFlags)
}

View file

@ -161,7 +161,7 @@ func SetFlags() error {
}
// Remove all flags definition, then set manifest' flags
res := regFlag.ReplaceAllLiteralString(string(content), "")
res := regFlagComplain.ReplaceAllLiteralString(string(content), "")
res = regProfileHeader.ReplaceAllLiteralString(res, flags)
if err := file.WriteFile([]byte(res)); err != nil {
return err