Skip to content

Commit dde7f65

Browse files
committed
fix: pass tests which use non-matching mod reference and .uplugin name
1 parent 288e7cf commit dde7f65

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

cli/installations.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,25 @@ func downloadAndExtractMod(modReference string, version string, link string, has
716716
}
717717

718718
func getExtractLocation(reader *zip.Reader, modReference string) (string, error) {
719-
upluginFile, err := reader.Open(fmt.Sprintf("%s.uplugin", modReference))
719+
var upluginFile *zip.File
720+
for _, file := range reader.File {
721+
if strings.HasSuffix(file.Name, ".uplugin") {
722+
upluginFile = file
723+
break
724+
}
725+
}
726+
if upluginFile == nil {
727+
return "", errors.New("no uplugin file found in zip")
728+
}
729+
730+
upluginReader, err := upluginFile.Open()
720731
if err != nil {
721-
return "", fmt.Errorf("failed to find uplugin file in zip: %w", err)
732+
return "", fmt.Errorf("failed to open uplugin file: %w", err)
722733
}
734+
defer upluginReader.Close()
723735

724736
var uplugin cache.UPlugin
725-
data, err := io.ReadAll(upluginFile)
737+
data, err := io.ReadAll(upluginReader)
726738
if err != nil {
727739
return "", fmt.Errorf("failed to read uplugin file: %w", err)
728740
}

0 commit comments

Comments
 (0)