merging in new additions to the pull request

This commit is contained in:
Jack Bennett 2014-03-05 14:49:23 +00:00
commit cf74dba780

View File

@ -48,8 +48,8 @@ function Ensure-Exists ($item) {
} }
function Ensure-Executable ($command) { function Ensure-Executable ($command) {
try { Get-Command $command -ErrorAction Stop > $null} try { Get-Command $command -ErrorAction Stop > $null }
catch{ catch {
Write-Error "Missing $command! Ensure it is installed and on in the PATH" Write-Error "Missing $command! Ensure it is installed and on in the PATH"
exit 1 exit 1
} }
@ -74,6 +74,14 @@ function Flatten-Directory ($name) {
Remove-Item -Recurse "$($name)_moving" Remove-Item -Recurse "$($name)_moving"
} }
function Extract-Archive ($source, $target) {
Invoke-Expression "7z x -y -o$($target) $source"
if ($lastexitcode -ne 0) {
Write-Error "Extracting of $source failied"
}
Remove-Item $source
}
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
# Check for requirements # Check for requirements
@ -92,8 +100,7 @@ foreach ($s in $sources) {
Delete-Existing $s.name Delete-Existing $s.name
Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop
Invoke-Expression "7z x -y -o$($s.name) $tempArchive > `$null" Extract-Archive $tempArchive $s.name
Remove-Item $tempArchive
if ((Get-Childitem $s.name).Count -eq 1) { if ((Get-Childitem $s.name).Count -eq 1) {
Flatten-Directory($s.name) Flatten-Directory($s.name)
@ -102,4 +109,4 @@ foreach ($s in $sources) {
} }
Pop-Location Pop-Location
Write-Output "All good and done!" Write-Output "All good and done!"