diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 1d06914..6a7891d 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -60,6 +60,17 @@ function Delete-Existing ($path) { Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue } +# Check for archives that were not extracted correctly +# when the folder contains another folder +function Flatten-Directory ($name) { + $child = (Get-Childitem $name)[0] + Rename-Item $name -NewName "$($name)_moving" + Move-Item -Path "$($name)_moving\$child" -Destination $name + Remove-Item -Recurse "$($name)_moving" +} + +$ErrorActionPreference = "Stop" + # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" @@ -68,23 +79,19 @@ Push-Location -Path $saveTo $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json foreach ($s in $sources) { - Write-Verbose "Getting $($s.name) from URL $($s.url)" + Write-Host "Getting $($s.name) from URL $($s.url)" # We do not care about the extensions/type of archive $tempArchive = "$($s.name).tmp" Delete-Existing $tempArchive Delete-Existing $s.name - Invoke-WebRequest -Uri $s.url -OutFile $tempArchive + Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop Invoke-Expression "7z x -y -o$($s.name) $tempArchive" Remove-Item $tempArchive - # Check for archives that were not extracted correctly if ((Get-Childitem $s.name).Count -eq 1) { - $child = (Get-Childitem $s.name)[0] - Rename-Item $s.name -NewName "$($s.name)_moving" - Move-Item -Path "$($s.name)_moving\$child" -Destination $s.name - Remove-Item -Recurse "$($s.name)_moving" + Flatten-Directory($s.name) } } diff --git a/vendor/sources.json b/vendor/sources.json index 73dd7e0..57aa1e3 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -12,7 +12,6 @@ { "name": "conemu-maximus5", "version": "140124", - "url": "http://conemu.codeplex.com/downloads/get/782952", - "package": "ConEmuPack.140124.7z" + "url": "https://conemu.codeplex.com/downloads/get/782952" } ] \ No newline at end of file