PowerShell_Scripts/Edit-DockerCompose.ps1

15 lines
554 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]param([string[]]$ProjectPath=@($PWD),[switch]$Force)
$local:editCandidates = @('docker-compose.yml','.base.docker-compose.yml')
$local:editFiles = @()
foreach( $local:fileName in $EditCandidates ) {
foreach( $local:path in $ProjectPath ) {
$local:testPath = Join-Path $path $fileName
if( $Force -or $(Test-Path $testPath) ) { $editFiles += $testPath }
}
}
Edit-TextFile $editFiles
$editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q }