Use the correct directories for non-mod files; use .pw.toml extension

The mods-folder option is now replaced with two new options: meta-folder and meta-folder-base
This allows non-mod files to use the correct directory based on their category; with correct
import of resource packs/etc from CurseForge packs, and the ability to override this behaviour.
To improve the reliability of packwiz metadata file marking (in the index), new files now use .pw.toml
as the extension - any extension can be used, but .pw.toml will now be automatically be
marked as a metafile regardless of folder, so you can easily move metadata files around.
Existing metadata files will still work (as metafile = true is set in the index); though in
the future .pw.toml may be required.
This commit is contained in:
comp500
2022-05-16 21:06:10 +01:00
parent d73c7e809b
commit 0f3096e251
8 changed files with 56 additions and 41 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/spf13/viper"
"os"
"path/filepath"
"regexp"
"strings"
@@ -207,10 +208,14 @@ func installVersion(mod Mod, version Version, pack core.Pack) error {
Update: updateMap,
}
var path string
folder := viper.GetString("meta-folder")
if folder == "" {
folder = "mods"
}
if mod.Slug != "" {
path = modMeta.SetMetaName(mod.Slug, index)
path = modMeta.SetMetaPath(filepath.Join(viper.GetString("meta-folder-base"), folder, mod.Slug+core.MetaExtension))
} else {
path = modMeta.SetMetaName(mod.Title, index)
path = modMeta.SetMetaPath(filepath.Join(viper.GetString("meta-folder-base"), folder, mod.Title+core.MetaExtension))
}
// If the file already exists, this will overwrite it!!!