mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-26 21:17:47 -04:00
matugen: keep user templates when config.toml has no [config] table (#3921)
This commit is contained in:
1 parent
0691242c9a
commit
ce7dcd7439
1 file changed
+3
-7
@@ -665,7 +665,7 @@ func userConfigSection(opts *Options) string {
|
||||
if err != nil {
|
||||
return "[config]\n\n"
|
||||
}
|
||||
section := extractTOMLSection(string(data), "[config]", "[templates]")
|
||||
section := extractTOMLSection(string(data), "[config]", "\n[templates")
|
||||
if section == "" {
|
||||
return "[config]\n\n"
|
||||
}
|
||||
@@ -741,7 +741,7 @@ output_path = '%s'
|
||||
|
||||
if opts.RunUserTemplates {
|
||||
if data, err := os.ReadFile(userConfigPath); err == nil {
|
||||
templatesSection := extractTOMLSection(string(data), "[templates]", "")
|
||||
templatesSection := extractTOMLSection("\n"+string(data), "\n[templates", "\n[config]")
|
||||
if templatesSection != "" {
|
||||
cfgFile.WriteString(templatesSection)
|
||||
cfgFile.WriteString("\n")
|
||||
@@ -1211,11 +1211,7 @@ func writeDryRunConfig(opts *Options) (string, error) {
|
||||
}
|
||||
defer cfgFile.Close()
|
||||
|
||||
section := userConfigSection(opts)
|
||||
if idx := strings.Index(section, "\n[templates"); idx != -1 {
|
||||
section = section[:idx+1]
|
||||
}
|
||||
cfgFile.WriteString(section)
|
||||
cfgFile.WriteString(userConfigSection(opts))
|
||||
cfgFile.WriteString("[templates]\n")
|
||||
return cfgFile.Name(), nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user