-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
48 lines (41 loc) · 1.82 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$destinationDir = "$env:APPDATA\Haskmate"
$sourceExe1 = ".\Haskmate.exe"
$sourceExe2 = ".\.stack-work\dist\ed8db9df\build\HaskMate\Haskmate.exe"
# Check if Haskmate directory is already in the PATH environment variable
$existingPath = [Environment]::GetEnvironmentVariable("PATH", "User")
$hasHaskmatePath = $existingPath -like "*$destinationDir*"
# Create the Haskmate directory if it doesn't exist
if (-not (Test-Path $destinationDir)) {
New-Item -ItemType Directory -Path $destinationDir -Force | Out-Null
}
# Check if Haskmate.exe already exists in the destination directory
$destinationExe = Join-Path -Path $destinationDir -ChildPath "Haskmate.exe"
if (Test-Path $destinationExe) {
Write-Host "Replacing existing Haskmate.exe in the Haskmate directory."
Remove-Item -Path $destinationExe -Force
}
# Copy the Haskmate executable to the destination directory
$sourcePath = $sourceExe1
if (-not (Test-Path $sourcePath)) {
Write-Host "Running from development environment."
$sourcePath = $sourceExe2
}
if (Test-Path $sourcePath) {
Copy-Item -Path $sourcePath -Destination $destinationExe -Force
} else {
Write-Host "Unable to find the Haskmate.exe file in the expected locations."
Write-Host "Please make sure the Haskmate executable is present and try again."
pause
exit
}
# Add the Haskmate directory to the PATH environment variable if not already present
if (-not $hasHaskmatePath) {
$newPath = $existingPath + ";" + $destinationDir
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
Write-Host "Haskmate directory added to the PATH environment variable."
}
# Display a message to confirm the setup
Write-Host "Haskmate setup complete."
Write-Host "Haskmate executable is located in: $destinationDir"
Write-Host "You can now run Haskmate from anywhere in the command prompt."
pause