From 9ac562ed9cb1aed1efe608a6840372f4d2104de6 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 16 Jun 2025 17:19:44 +0300 Subject: [PATCH] Features: *(none)*; Fixes: 1) Add `-Force` flag to `New-Item` to overwrite environment variables if they already exist; Extra: 1) Remove unused spinner logic from script for better readability and maintainability. --- scripts/Windows/export-environment-file.ps1 | 35 +-------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/scripts/Windows/export-environment-file.ps1 b/scripts/Windows/export-environment-file.ps1 index c05d4a5b..234875cd 100644 --- a/scripts/Windows/export-environment-file.ps1 +++ b/scripts/Windows/export-environment-file.ps1 @@ -25,39 +25,6 @@ $art -split "`r?`n" | ForEach-Object { Write-Host "`n by WISELESS TEAM`n" -ForegroundColor Gray -$Spinner = @('|', '/', '-', '\') -$Colors = @('White', 'Gray') -$Delay = 100 - -function Invoke-Spinner -{ - [CmdletBinding()] - param( - [Parameter(Mandatory)][string]$Arguments, - [Parameter(Mandatory)][string]$Message - ) - Write-Host -NoNewLine -ForegroundColor Cyan ("{0}… " -f $Message) - $si = New-Object System.Diagnostics.ProcessStartInfo - $si.FileName = "docker" - $si.Arguments = "$Arguments --ansi never" - $si.RedirectStandardOutput = $true - $si.RedirectStandardError = $true - $si.UseShellExecute = $false - $p = [System.Diagnostics.Process]::Start($si) - $i = 0 - while (-not $p.HasExited) - { - $frame = $Spinner[$i % $Spinner.Length] - $col = $Colors[$i % $Colors.Length] - Write-Host -NoNewLine -ForegroundColor $col $frame - Start-Sleep -Milliseconds $Delay - Write-Host -NoNewLine "`b" - $i++ - } - $p.WaitForExit() - Write-Host -ForegroundColor Green "✔" -} - $envFile = '.env' if (-not (Test-Path $envFile)) @@ -94,7 +61,7 @@ Get-Content $envFile | ForEach-Object { $value = $value.Substring(1, $value.Length - 2) } - New-Item -Path Env:\$key -Value $value | Out-Null + New-Item -Force -Path Env:\$key -Value $value | Out-Null $envVars[$key] = $value }