PowerShell_Scripts/docker/Edit-DockerCompose.ps1

29 lines
872 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]param(
[ArgumentCompleter({ param (
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters
)
[DockerComposeDirs]::_GetValidValues($wordToComplete,$true)
})]
[string[]]$ProjectPath=@($PWD),
[switch]$Force,
[string[]]$AdditionalFiles
)
$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 | Sort-Object) + $AdditionalFiles)
$editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q }