Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Dec 11, 2024
2 parents 1e9f9bc + 6ff2764 commit aa9ded4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
run: |
powershell -NoProfile -ExecutionPolicy unrestricted ./install.ps1 -InstallDir '%cd%\install folder with spaces'
- name: Check MetaCall is installed
- name: Install Test
shell: cmd
run: |
dir "%cd%\install folder with spaces"
Expand Down
45 changes: 40 additions & 5 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
.PARAMETER FromPath
Default: $null
Path to the tarball to be installed. If specified, this parameter will override the Version parameter.
.PARAMETER Uninstall
Removes MetaCall from the specified installation directory and clears its entry from the PATH environment variable.
If this parameter is specified, the script will perform an uninstallation rather than an installation.
#>

[cmdletbinding()]
param(
[string]$InstallDir="<auto>",
[string]$Version="latest",
[string]$FromPath=$null
[string]$FromPath=$null,
[switch]$Uninstall=$false
)

Set-StrictMode -Version Latest
Expand Down Expand Up @@ -223,7 +227,6 @@ function Path-Install([string]$InstallRoot) {
}
}

# TODO: Use this for implementing uninstall
function Path-Uninstall([string]$Path) {
$PersistedPaths = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::User) -split ';'
if ($PersistedPaths -contains $Path) {
Expand Down Expand Up @@ -300,7 +303,7 @@ function Set-NodePath {
[string]$FilePath
)

if (-not (Test-Path "$FilePath")) {
if (-not (Test-Path $FilePath)) {
Print-Error "Failed to set up an additional package, the file $FilePath does not exist."
return
}
Expand Down Expand Up @@ -338,5 +341,37 @@ function Install-Additional-Packages {
Print-Success "Package '$Component' has been installed."
}

# Install the tarball and post scripts
Install-Tarball $InstallDir $Version
function Uninstall([string]$InstallDir) {
Print-Title "MetaCall Uninstallation"

$InstallRoot = Resolve-Installation-Path $InstallDir

if (-not (Test-Path $InstallRoot)) {
Print-Error "Failed to uninstall MetaCall, the folder $InstallRoot does not exist."
return
}

Print-Info "Removing MetaCall files."

# Delete MetaCall files from the install directory
Remove-Item -Recurse -Force $InstallRoot

if (-not (Test-Path $InstallRoot)) {
Print-Debug "MetaCall files removed from: $InstallRoot successfully"
}

Print-Info "Removing MetaCall from PATH."

# Call the Path-Uninstall function to remove from PATH
Path-Uninstall $InstallRoot

Print-Success "MetaCall uninstallation completed."
}

if ($Uninstall) {
# Uninstall the metacall and remove path
Uninstall $InstallDir
} else {
# Install the tarball and post scripts
Install-Tarball $InstallDir $Version
}

0 comments on commit aa9ded4

Please sign in to comment.