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 = @() $local:editFiles = @()
foreach( $local:fileName in $EditCandidates ) { foreach( $local:ext in @('.yml', '.yaml') ) {
foreach( $local:path in $ProjectPath ) { $local:rawEditCandidates = $EditCandidates | ForEach-Object { $_ -replace '\.###',$ext }
$local:testPath = Join-Path $path $fileName foreach( $local:fileName in $rawEditCandidates ) {
if( $Force -or $(Test-Path $testPath) ) { $editFiles += $testPath } 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) Edit-TextFile ($($editFiles | Sort-Object) + $AdditionalFiles)
$editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q } $editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q }