Handle PATH, InstallLocation, and ATOM_HOME

This commit is contained in:
confused-Techie 2023-06-20 21:46:58 -07:00
parent ec5fdc6c2b
commit 1c3fb0bb24
3 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,23 @@
!macro customInstall
# Set the 'InstallLocation' Registry Key for GitHub Desktop
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "InstallLocation" "$INSTDIR"
# Add Pulsar to the PATH, depending on if this is user install or machine
${if} $installMode === "all"
# Machine Install
ExecWait "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\modifyWindowsPath.ps1 -installMode Machine -installdir $INSTDIR -remove 0"
${else}
# User Install
ExecWait "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\modifyWindowsPath.ps1 -installMode User -installdir $INSTDIR -remove 0"
${endif}
!macroend
!macro customUninstall
# This uninstall script is ready to go. Just a question if we want to modify PATH on uninstall
${if} $installMode === "all"
# Machine Install
ExecWait "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\modifyWindowsPath.ps1 -installMode Machine -installdir $INSTDIR -remove 1"
${else}
# User Install
ExecWait "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\modifyWindowsPath.ps1 -installMode User -installdir $INSTDIR -remove 1"
${endif}
!macroend

View File

@ -0,0 +1,28 @@
# This is all handled within a PowerShell file to avoid length limits within NSIS Scripts
# And to avoid having to include plugins for NSIS, PowerShell can do this natively
# -remove 0 is FALSE | -remove 1 is TRUE
param ($installMode,$installdir,[boolean]$remove=$false)
if (-not $remove) {
if ($installMode -eq "User" -or $installMode -eq "Machine") {
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$installdir\resources;$installdir\resources\app\ppm\bin", $installMode)
}
# Now only add the ATOM_HOME env var if a user install, since we don't have a plan
# on it's location for a machine install
if ($installMode -eq "User") {
[Environment]::SetEnvironmentVariable("ATOM_HOME", "$env:USERPROFILE\.pulsar", "User")
}
} else {
if ($installMode -eq "User" -or $installMode -eq "Machine") {
$path = [Environment]::GetEnvironmentVariable("PATH", $installMode)
# Remove unwanted element from path
$path = ($path.Split(";") | Where-Object { $_ -ne "$installdir\resources" }) -join ";"
$path = ($path.Split(";") | Where-Object { $_ -ne "$installdir\resources\app\ppm\bin" }) -join ";"
# Set our new path
[Environment]::SetEnvironmentVariable("Path", $path, $installMode)
} # Else we have been given bad params, and will silently exit
if ($installMode -eq "User") {
[Environment]::SetEnvironmentVariable("ATOM_HOME", $null, "User")
}
}

View File

@ -213,6 +213,10 @@ let options = {
"from": "resources/win/pulsar.js",
"to": "pulsar.js"
},
{
"from": "resources/win/modifyWindowsPath.ps1",
"to": "modifyWindowsPath.ps1"
}
],
"target": [
{ "target": "nsis" },
@ -227,11 +231,12 @@ let options = {
"runAfterFinish": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"guid": "0949b555-c22c-56b7-873a-a960bdefa81f"
"guid": "0949b555-c22c-56b7-873a-a960bdefa81f",
// The GUID is generated from Electron-Builder based on our AppID
// Hardcoding it here means it will always be used as generated from
// the AppID 'dev.pulsar-edit.pulsar'. If this value ever changes,
// A PR to GitHub Desktop must be made with the updated value
"include": "resources/win/installer.nsh"
},
"extraMetadata": {
},