Fixes and completion of Invoke-DockerCompose
This commit is contained in:
parent
dcc9113cda
commit
a7ac392886
3 changed files with 23 additions and 15 deletions
|
@ -62,7 +62,7 @@ foreach( $local:p in $CliParams ) {
|
|||
$local:AsJob = $false;
|
||||
$local:Wait = $false;
|
||||
|
||||
if( $p -isnot [String] ) {
|
||||
if( $p -isnot [String] -or $p.Length -eq 1 ) {
|
||||
$local:skipFirst = $true
|
||||
switch( $p[0] ) {
|
||||
'&' { $AsJob = $true }
|
||||
|
@ -72,7 +72,8 @@ foreach( $local:p in $CliParams ) {
|
|||
if( $skipFirst ) { $p = $p | Select-Object -Skip 1 }
|
||||
}
|
||||
|
||||
$dcParams = $p | Where-Object { $_ } | ForEach-Object {
|
||||
$local:dcParams=@()
|
||||
$local:dcParams = $p | Where-Object { $_ } | ForEach-Object {
|
||||
if( $_ -match "(?:^'[^']+'$)|(?:^`"[^`"]+`"$)|(?:^[^\s]+$)" ) { $_ }
|
||||
else { "'$($_.Replace( "'", "''" ))'" }
|
||||
}
|
||||
|
@ -81,16 +82,22 @@ foreach( $local:p in $CliParams ) {
|
|||
$local:dcPath = Join-Path $_ 'docker-compose.yml'
|
||||
if( -not (Test-Path $dcPath) ) { if( $Recurse ) { return } else { throw "ERROR: dcPath ($dcPath) does not exists" } }
|
||||
|
||||
Write-Verbose "& docker-compose --file $dcPath $dcParams"
|
||||
if( $Wait -and -not $WhatIfPreference ) {
|
||||
CompleteJobs
|
||||
}
|
||||
|
||||
if( -not $dcParams ) { continue }
|
||||
|
||||
if( $Wait ) {
|
||||
if( $WhatIfPreference ) {
|
||||
Write-Host "In $dcPath Run $(if($AsJob){"(bg) "})with: $dcParams"
|
||||
} elseif( $AsJob ) {
|
||||
Write-Host -ForegroundColor DarkCyan "Wait for bg jobs to complete !"
|
||||
} else {
|
||||
CompleteJobs
|
||||
}
|
||||
}
|
||||
|
||||
if( -not $dcParams ) { continue }
|
||||
|
||||
if( $WhatIfPreference ) {
|
||||
Write-Host "In $dcPath Run $(if($AsJob){"(bg) "})with: $dcParams"
|
||||
} else {
|
||||
Write-Verbose "& docker-compose --file $dcPath $dcParams"
|
||||
|
||||
if( $AsJob ) {
|
||||
$JobQueue += Start-Job -ArgumentList @($dcPath,$dcParams) -ScriptBlock {
|
||||
param($dcPath,$dcParams)
|
||||
[PSCustomObject] $([ordered]@{
|
||||
|
@ -102,9 +109,9 @@ foreach( $local:p in $CliParams ) {
|
|||
} else {
|
||||
& docker-compose --file $dcPath $dcParams
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# if( $WhatIfPreference ) { return }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue