Skip to content

Commit

Permalink
fix: support powershell 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Dec 4, 2024
1 parent 5565896 commit 2c90496
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Download the most recent [release](https://github.com/UCSD-E4E/git-lfs-synology/
#### Windows
These install scripts install `git-lfs-synology` globally. This will impact all git repos on your system. Please install manually if this is something that you need to avoid.

Please install this using PowerShell as your user. Do NOT execute this from an admin shell.

```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/UCSD-E4E/git-lfs-synology/refs/heads/main/scripts/install.ps1?bust=$((Get-Date).Ticks)).Content; Invoke-InstallScript
```
Expand Down
25 changes: 18 additions & 7 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ function Invoke-InstallScript {
"*Darwin*" { "osx" } # MacOS is identified as Darwin
Default { "unknown" }
}
$arch = switch ($architecture) {
"X64" { "x86_64" }
"Arm64" { "aarch64" }
Default { "unknown" }

if ($osPlatform -ne "win") {
$arch = switch ($env:PROCESSOR_ARCHITECTURE) {
"AMD64" { "x86_64 "}
"ARM64" { "aarch64" }
Default { "unknown" }
}
}
else {
# Not Windows
$arch = switch ($architecture) {
"X64" { "x86_64" }
"Arm64" { "aarch64" }
Default { "unknown" }
}
}

# Construct the asset name.
Expand Down Expand Up @@ -59,7 +70,7 @@ function Invoke-InstallScript {

# Update the Path Environment Variable
if (-not ($targetPath -in $env:PATH)) {
if ($IsWindows) {
if ($osPlatform -eq "win") {
$seperator = ";"
}
else {
Expand All @@ -68,7 +79,7 @@ function Invoke-InstallScript {

$env:PATH = "$($targetPath)$($seperator)$($env:PATH)"

if ($IsWindows) {
if ($osPlatform -eq "win") {
# This only works on Windows.
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User)
}
Expand All @@ -81,7 +92,7 @@ function Invoke-InstallScript {
git-lfs-synology login --url $URL --user $User

# Get the suffix
if ($IsWindows) {
if ($osPlatform -eq "win") {
$suffix = ".exe"
}
else {
Expand Down

0 comments on commit 2c90496

Please sign in to comment.