mirror of
https://github.com/ducaale/xh.git
synced 2025-05-05 15:32:50 +00:00
Improve case-insensitivity in path check and streamline install script output
This commit is contained in:
parent
1e3c058651
commit
766933963b
25
install.ps1
25
install.ps1
@ -47,21 +47,20 @@ $userPath = [System.Environment]::GetEnvironmentVariable('Path', [System.Environ
|
|||||||
$machinePath = [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine)
|
$machinePath = [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine)
|
||||||
|
|
||||||
# If userPath AND machinePath both do not contain bin, then add it to user path
|
# If userPath AND machinePath both do not contain bin, then add it to user path
|
||||||
if (!($userPath -contains $destdir) -and !($machinePath -contains $destdir))
|
if (!($userPath.ToLower().Contains($destdir.ToLower())) -and !($machinePath.ToLower().Contains($destdir.ToLower())))
|
||||||
{
|
{
|
||||||
Write-Output "PATH did not contain $destdir"
|
|
||||||
|
|
||||||
# Update userPath
|
# Update userPath
|
||||||
$userPath = $userPath.Trim(";") + ";$destdir"
|
$userPath = $userPath.Trim(";") + ";$destdir"
|
||||||
|
|
||||||
# Modify PATH for new windows
|
# Modify PATH for new windows
|
||||||
Write-Output "Adding $destdir to user PATH."
|
Write-Output "`nAdding $destdir directory to the PATH variable."
|
||||||
[System.Environment]::SetEnvironmentVariable('Path', $userPath, [System.EnvironmentVariableTarget]::User)
|
[System.Environment]::SetEnvironmentVariable('Path', $userPath, [System.EnvironmentVariableTarget]::User)
|
||||||
Write-Output "Done."
|
|
||||||
|
# Modify PATH for current terminal
|
||||||
# Instruct how to modify PATH for the current window
|
Write-Output "`nRefreshing current terminal's PATH for you."
|
||||||
Write-Output "Execute the following command to make xh usable immediately in PowerShell:"
|
$Env:Path = $Env:Path.Trim(";") + ";$destdir"
|
||||||
Write-Host "`$Env:Path = `$Env:Path.Trim(`";`") + `";$destdir`"" -foreground yellow
|
|
||||||
|
# Instruct how to modify PATH for other open terminals
|
||||||
Write-Host "Or restart any terminal to refresh its PATH and use xh."
|
Write-Output "`nFor other terminals, restart them (or the entire IDE if they're within one).`n"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user