11$InstallDir = " $env: LOCALAPPDATA \ShellLite"
22$ExePath = Join-Path $PSScriptRoot " shlcpp.exe"
33if (-not (Test-Path $ExePath )) {
4- Write-Error " shlcpp.exe not found in current directory. Please run this after building."
5- exit
4+ if (Test-Path (Join-Path $PSScriptRoot " build_cpp\Release\shell_lite_exec.exe" )) {
5+ $ExePath = Join-Path $PSScriptRoot " build_cpp\Release\shell_lite_exec.exe"
6+ } elseif (Test-Path (Join-Path $PSScriptRoot " build_cpp\Release\shlcpp.exe" )) {
7+ $ExePath = Join-Path $PSScriptRoot " build_cpp\Release\shlcpp.exe"
8+ } else {
9+ Write-Error " shlcpp.exe not found. Please place or build shlcpp.exe first."
10+ exit 1
11+ }
612}
713Write-Host " Installing ShellLite to $InstallDir ..."
814if (-not (Test-Path $InstallDir )) {
9- New-Item - ItemType Directory - Path $InstallDir
15+ New-Item - ItemType Directory - Path $InstallDir | Out-Null
1016}
11- Copy-Item $ExePath - Destination $InstallDir - Force
17+ Copy-Item $ExePath - Destination ( Join-Path $InstallDir " shlcpp.exe " ) - Force
1218Write-Host " ShellLite binary copied."
19+
20+ $DllPath = Join-Path $PSScriptRoot " shell_lite_lib.dll"
21+ if (-not (Test-Path $DllPath ) -and (Test-Path (Join-Path $PSScriptRoot " build_cpp\Release\shell_lite_lib.dll" ))) {
22+ $DllPath = Join-Path $PSScriptRoot " build_cpp\Release\shell_lite_lib.dll"
23+ }
24+ if (Test-Path $DllPath ) {
25+ Copy-Item $DllPath - Destination $InstallDir - Force
26+ Write-Host " ShellLite shared library copied."
27+ }
28+
1329$StdLibPath = Join-Path $PSScriptRoot " shell_lite\stdlib"
1430if (Test-Path $StdLibPath ) {
31+ $DestStdLib = Join-Path $InstallDir " stdlib"
32+ if (Test-Path $DestStdLib ) {
33+ Remove-Item $DestStdLib - Recurse - Force
34+ }
1535 Copy-Item - Path $StdLibPath - Destination $InstallDir - Recurse - Force
1636 Write-Host " ShellLite standard library copied."
1737}
1838$UserPath = [Environment ]::GetEnvironmentVariable(" Path" , " User" )
19- if ($UserPath -notlike " *$InstallDir *" ) {
39+ $PathEntries = if ($UserPath ) { ($UserPath -split ' ;' ) | Where-Object { $_ } } else { @ () }
40+ if ($PathEntries -notcontains $InstallDir ) {
2041 Write-Host " Adding $InstallDir to User PATH..."
21- [Environment ]::SetEnvironmentVariable(" Path" , $UserPath + " ;" + $InstallDir , " User" )
42+ $NewPath = if ($UserPath ) { " $UserPath ;$InstallDir " } else { $InstallDir }
43+ [Environment ]::SetEnvironmentVariable(" Path" , $NewPath , " User" )
2244 Write-Host " PATH updated. Please restart your terminal."
2345} else {
2446 Write-Host " ShellLite is already in your PATH."
2547}
48+
49+ $UserPathext = [Environment ]::GetEnvironmentVariable(" PATHEXT" , " User" )
50+ $PathextEntries = if ($UserPathext ) { ($UserPathext -split ' ;' ) | Where-Object { $_ } } else { @ () }
51+ if ($PathextEntries -notcontains " .SHL" ) {
52+ $NewPathext = if ($UserPathext ) { " $UserPathext ;.SHL" } else { " .SHL" }
53+ [Environment ]::SetEnvironmentVariable(" PATHEXT" , $NewPathext , " User" )
54+ }
55+
2656Write-Host " `n Installation complete! You can now run 'shlcpp' from any terminal." - ForegroundColor Green
0 commit comments