diff --git a/get-game-versions.ps1 b/get-game-versions.ps1 index d90ec0c..9d21c3a 100644 --- a/get-game-versions.ps1 +++ b/get-game-versions.ps1 @@ -12,7 +12,10 @@ function Validate-SecretsFile { if ($null -eq $IsWindows -or $IsWindows) { # The script is running on Windows, use curl.exe - curl.exe -H X-Api-Token:$CURSEFORGE_TOKEN https://minecraft.curseforge.com/api/game/versions >> game-versions.json -} else { - curl -H X-Api-Token:$CURSEFORGE_TOKEN https://minecraft.curseforge.com/api/game/versions >> game-versions.json + $curl = "curl.exe" } +else { + $curl = "curl" +} + +& $curl -H X-Api-Token:$CURSEFORGE_TOKEN https://minecraft.curseforge.com/api/game/versions >> game-versions.json diff --git a/modpack-uploader.ps1 b/modpack-uploader.ps1 index 3b1e38e..06a6b2d 100644 --- a/modpack-uploader.ps1 +++ b/modpack-uploader.ps1 @@ -52,12 +52,7 @@ function Test-ForDependencies { throw "7zip not command available. Please follow the instructions above." } - if ($IsWindows) { - $isCurlAvailable = Get-Command curl.exe - } - else { - $isCurlAvailable = Get-Command curl - } + $isCurlAvailable = Get-Command $curl if (-not $isCurlAvailable) { Clear-Host @@ -69,7 +64,7 @@ function Test-ForDependencies { Write-Host Write-Host "When you're done, rerun this script.`n" - throw "curl or curl.exe command not available. Please follow the instructions above." + throw "curl not available. Please follow the instructions above." } } @@ -242,26 +237,15 @@ function Push-ClientFiles { Write-Host "Uploading client files to https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" -ForegroundColor Green Write-Host - if ($IsWindows) { - $response = curl.exe ` - --url "https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" ` - --user "$CURSEFORGE_USER`:$CURSEFORGE_TOKEN" ` - -H "Accept: application/json" ` - -H X-Api-Token:$CURSEFORGE_TOKEN ` - -F metadata=$CLIENT_METADATA ` - -F file=@"$CLIENT_ZIP_NAME.zip" ` - --progress-bar | ConvertFrom-Json - } - else { - $response = curl ` - --url "https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" ` - --user "$CURSEFORGE_USER`:$CURSEFORGE_TOKEN" ` - -H "Accept: application/json" ` - -H X-Api-Token:$CURSEFORGE_TOKEN ` - -F metadata=$CLIENT_METADATA ` - -F file=@"$CLIENT_ZIP_NAME.zip" ` - --progress-bar | ConvertFrom-Json - } + $response = & $curl ` + --url "https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" ` + --user "$CURSEFORGE_USER`:$CURSEFORGE_TOKEN" ` + -H "Accept: application/json" ` + -H X-Api-Token:$CURSEFORGE_TOKEN ` + -F metadata=$CLIENT_METADATA ` + -F file=@"$CLIENT_ZIP_NAME.zip" ` + --progress-bar | ConvertFrom-Json + $clientFileReturnId = $response.id @@ -345,27 +329,14 @@ function Push-ServerFiles { Write-Host "Uploading server files..." -ForegroundColor Cyan Write-Host - if ($IsWindows) { - - $serverFileResponse = curl.exe ` - --url "https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" ` - --user "$CURSEFORGE_USER`:$CURSEFORGE_TOKEN" ` - -H "Accept: application/json" ` - -H X-Api-Token:$CURSEFORGE_TOKEN ` - -F metadata=$SERVER_METADATA ` - -F file=@$serverFilePath ` - --progress-bar | ConvertFrom-Json - } - else { - $serverFileResponse = curl ` - --url "https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" ` - --user "$CURSEFORGE_USER`:$CURSEFORGE_TOKEN" ` - -H "Accept: application/json" ` - -H X-Api-Token:$CURSEFORGE_TOKEN ` - -F metadata=$SERVER_METADATA ` - -F file=@$serverFilePath ` - --progress-bar | ConvertFrom-Json - } + $serverFileResponse = & $curl ` + --url "https://minecraft.curseforge.com/api/projects/$CURSEFORGE_PROJECT_ID/upload-file" ` + --user "$CURSEFORGE_USER`:$CURSEFORGE_TOKEN" ` + -H "Accept: application/json" ` + -H X-Api-Token:$CURSEFORGE_TOKEN ` + -F metadata=$SERVER_METADATA ` + -F file=@$serverFilePath ` + --progress-bar | ConvertFrom-Json if ($serverFileResponse.errorCode) { throw "Failed to upload server files: $serverFileResponse" @@ -433,10 +404,10 @@ Set-Location $INSTANCE_ROOT if ($null -eq $IsWindows -or $IsWindows) { # The script is running on Windows, use curl.exe - $IsWindows = $true + $curl = "curl.exe" } else { - $IsWindows = $false + $curl = "curl" } Test-ForDependencies