@@ -10,19 +10,9 @@ $environmentName = $null
1010
1111function Normalize-EnvironmentName {
1212 param ([Parameter (Mandatory )][string ] $Value )
13-
14- $normalized = $Value.ToLowerInvariant ()
15- $normalized = [Regex ]::Replace($normalized , ' [^a-z0-9]+' , ' -' )
16- $normalized = $normalized.Trim (' -' )
17-
18- if ([string ]::IsNullOrWhiteSpace($normalized )) {
19- throw " Environment name '$Value ' does not contain any supported characters."
20- }
21-
22- if ($normalized.Length -gt $maximumEnvironmentNameLength ) {
23- $normalized = $normalized.Substring (0 , $maximumEnvironmentNameLength ).TrimEnd(' -' )
24- }
25-
13+ $normalized = [Regex ]::Replace($Value.ToLowerInvariant (), ' [^a-z0-9]+' , ' -' ).Trim(' -' )
14+ if ([string ]::IsNullOrWhiteSpace($normalized )) { throw " Environment name '$Value ' does not contain any supported characters." }
15+ if ($normalized.Length -gt $maximumEnvironmentNameLength ) { $normalized = $normalized.Substring (0 , $maximumEnvironmentNameLength ).TrimEnd(' -' ) }
2616 return $normalized
2717}
2818
@@ -38,25 +28,13 @@ foreach ($argument in $args) {
3828 }
3929}
4030
41- if ([string ]::IsNullOrWhiteSpace($environmentName )) {
42- $environmentName = Split-Path - Leaf $repositoryRoot
43- }
44-
31+ if ([string ]::IsNullOrWhiteSpace($environmentName )) { $environmentName = Split-Path - Leaf $repositoryRoot }
4532$normalizedEnvironmentName = Normalize- EnvironmentName $environmentName
46- $portMode = if ($normalizedEnvironmentName -in @ (' debug' , ' test' )) { $normalizedEnvironmentName } else { ' dynamic' }
33+ $portMode = if ($normalizedEnvironmentName -in @ (' debug' , ' test' , ' ci ' )) { $normalizedEnvironmentName } else { ' dynamic' }
4734$projectName = " $projectPrefix -$normalizedEnvironmentName "
48- $composeArguments = @ (
49- ' compose' ,
50- ' --project-name' , $projectName ,
51- ' --file' , (Join-Path $scriptDirectory ' docker-compose.yml' ),
52- ' --file' , (Join-Path $scriptDirectory " docker-compose.$portMode .yml" ),
53- ' down'
54- )
55-
35+ $composeArguments = @ (' compose' , ' --project-name' , $projectName , ' --file' , (Join-Path $scriptDirectory ' docker-compose.yml' ), ' --file' , (Join-Path $scriptDirectory " docker-compose.$portMode .yml" ), ' down' )
5636if ($removeData ) { $composeArguments += ' --volumes' }
5737
5838Write-Host " Stopping '$projectName '..."
5939& docker @composeArguments
60- if ($LASTEXITCODE -ne 0 ) {
61- throw " Docker Compose failed with exit code $LASTEXITCODE ."
62- }
40+ if ($LASTEXITCODE -ne 0 ) { throw " Docker Compose failed with exit code $LASTEXITCODE ." }
0 commit comments