Add pack-root option (fixes #27)

This commit is contained in:
comp500
2021-06-04 02:10:29 +01:00
parent d6bed7ad4c
commit 8cbe7d4c61
7 changed files with 26 additions and 15 deletions

View File

@@ -11,8 +11,9 @@ import (
const ModExtension = ".toml"
// ResolveMod returns the path to a mod file from it's name
func ResolveMod(modName string) string {
func ResolveMod(modName string, index Index) string {
// TODO: should this work for any metadata file?
fileName := strings.ToLower(strings.TrimSuffix(modName, ModExtension)) + ModExtension
return filepath.Join(viper.GetString("mods-folder"), fileName)
modsDir := filepath.Join(index.GetPackRoot(), viper.GetString("mods-folder"))
return filepath.Join(modsDir, fileName)
}