Skip to content

Commit b7b2628

Browse files
committed
Refactor PATH environment variable update in install.ps1
Modified the logic for updating the user's PATH environment variable in the install.ps1 script. The change ensures that the PATH is set correctly whether or not it already contains a value, improving the installation process for the CodeCrafters CLI on Windows.
1 parent fa79f38 commit b7b2628

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

install.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ try {
5151

5252
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
5353
if ($UserPath -notlike "*$InstallDir*") {
54-
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
54+
$NewUserPath = if ($UserPath) { "$UserPath;$InstallDir" } else { $InstallDir }
55+
[Environment]::SetEnvironmentVariable("Path", $NewUserPath, "User")
5556
$env:Path += ";$InstallDir"
5657
}
5758
Write-Host "Done!"

0 commit comments

Comments
 (0)