Skip to content

Commit

Permalink
use DownloadFile when using an Outputfile for HttpResource
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Dec 18, 2015
1 parent ed2eb03 commit c8458dd
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions BoxStarter.Common/Get-HttpResource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ http://boxstarter.org
$wp.UseDefaultCredentials=$true
$downloader.Proxy=$wp
try {
$httpString = $downloader.DownloadString($args[0])
if($args[1]) {
Write-BoxstarterMessage "Saving $httpString to $($args[1])" -Verbose
if(Test-Path $args[1]){Remove-Item $args[1] -Force}
$httpString | Out-File -FilePath $args[1] -Encoding utf8
Write-BoxstarterMessage "Saving $($args[0]) to $($args[1])" -Verbose
$downloader.DownloadFile($args[0], $args[1])
}
else {
$downloader.DownloadString($args[0])
}
$httpString
}
catch{
if($VerbosePreference -eq "Continue"){
Expand All @@ -57,5 +57,12 @@ http://boxstarter.org
}
} $Url $OutputPath

if($PassThru) { Write-Output $str }
if($PassThru) {
if($str) {
Write-Output $str
}
elseif($OutputPath) {
Get-Content -Path $OutputPath
}
}
}

0 comments on commit c8458dd

Please sign in to comment.