Improvements and bug fixes
dcl, dcll and dcre were brokeen, fixed that Invoke-WebDownload given a URL, automatically deduce the file file. Get-GitHubReleaseAssets - Grab URLs from a GitHub release page. Invoke-DockerCompose updated to display progress while waiting on background jobs.
This commit is contained in:
parent
53226f09b4
commit
f947b0b3b4
7 changed files with 122 additions and 21 deletions
44
base/Invoke-WebDownload.ps1
Normal file
44
base/Invoke-WebDownload.ps1
Normal file
|
@ -0,0 +1,44 @@
|
|||
[CmdletBinding()]param(
|
||||
[Parameter(Position=1)]
|
||||
[string]$OutputPath,
|
||||
[Parameter(Mandatory,Position=0,ValueFromPipeline)]
|
||||
[string]$Url,
|
||||
[switch]$Force,
|
||||
[switch]$PassThru
|
||||
)
|
||||
|
||||
process {
|
||||
$local:outputFileName=[string]::Empty
|
||||
if( -not $OutputPath ) {
|
||||
$OutputPath = Join-Path $(Get-Item $PWD) ''
|
||||
} elseif( Test-Path -Type Container $OutputPath ) {
|
||||
$OutputPath = Join-Path $(Get-Item $OutputPath) ''
|
||||
}
|
||||
|
||||
if( $OutputPath -notmatch '[/\\]$' ) {
|
||||
$outputFileName = Split-Path -Leaf $OutputPath
|
||||
$OutputPath = Join-Path $(Split-Path -Parent $OutputPath) ''
|
||||
}
|
||||
|
||||
if( -not (Test-Path $OutputPath) -and $Force ) {
|
||||
New-Item -Type Directory $OutputPath
|
||||
}
|
||||
|
||||
if( -not (Test-Path $OutputPath) ) { throw "Destination $OutputPath does not exists, aborting!" }
|
||||
|
||||
if( -not $outputFileName ) {
|
||||
$outputFileName = Split-Path -Leaf $Url
|
||||
}
|
||||
|
||||
$outputFileName = Join-Path $OutputPath $outputFileName
|
||||
|
||||
if( (Test-Path $outputFileName) -and -not $Force) {
|
||||
throw "$OutputPath already exists"
|
||||
}
|
||||
|
||||
Write-Verbose "About to start download from:`n`t$Url`n`tto`n`t$outputFileName`n"
|
||||
|
||||
Invoke-WebRequest -Uri $Url -OutFile $outputFileName
|
||||
|
||||
if( $PassThru ) { Get-Item $outputFileName }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue