Added support to Dockerfile and env in dcedit

This commit is contained in:
Gal Szkolnik 2021-01-14 17:24:29 -05:00
parent b8c343d908
commit c552452ac4
1 changed files with 17 additions and 5 deletions

View File

@ -14,15 +14,27 @@
)
$local:editCandidates = @('docker-compose.yml','.base.docker-compose.yml','Dockerfile')
$local:EditCandidates = @('docker-compose.###','.base.docker-compose.###')
$local:EditBonus = @('Dockerfile', '.env', '*.env')
$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 }
foreach( $local:ext in @('.yml', '.yaml') ) {
$local:rawEditCandidates = $EditCandidates | ForEach-Object { $_ -replace '\.###',$ext }
foreach( $local:fileName in $rawEditCandidates ) {
foreach( $local:path in $ProjectPath ) {
$local:testPath = Join-Path $path $fileName
if( $Force -or $(Test-Path $testPath) ) {
$editFiles += $testPath
$editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1
}
}
}
if( -not $editFiles ) { continue }
break
}
Edit-TextFile ($($editFiles | Sort-Object) + $AdditionalFiles)
$editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q }