Skip to content

Commit

Permalink
Assume zip means resourcepack.
Browse files Browse the repository at this point in the history
  • Loading branch information
dscalzi committed Mar 18, 2023
1 parent 6b2d9ed commit 3efef73
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/parser/CurseForgeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,21 @@ export class CurseForgeParser {
const modInfo = (await CurseForgeParser.cfClient.get<CurseForgeModFileResponse>(`mods/${file.projectID}/files/${file.fileID}`)).body
log.debug(`Downloading ${modInfo.data.fileName}`)

const isJar = modInfo.data.fileName.toLowerCase().endsWith('jar')
let dir: string
const fileNameLower = modInfo.data.fileName.toLowerCase()
if(fileNameLower.endsWith('jar')) {
dir = file.required ? requiredPath : optionalPath
}
else if(fileNameLower.endsWith('zip')) {
// Assume it's a resource pack.
dir = join(createServerResult.miscFileContainer, 'resourcepacks')
await mkdirs(dir)
}
else {
dir = createServerResult.miscFileContainer
}

const downloadStream = got.stream(modInfo.data.downloadUrl)
const dir = isJar ? file.required ? requiredPath : optionalPath : createServerResult.miscFileContainer
const fileWriterStream = createWriteStream(join(dir, modInfo.data.fileName))

await pipeline(downloadStream, fileWriterStream)
Expand Down

0 comments on commit 3efef73

Please sign in to comment.