-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
42 lines (33 loc) · 1.2 KB
/
install.ps1
File metadata and controls
42 lines (33 loc) · 1.2 KB
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
[CmdletBinding()]
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$InstallerArgs
)
$ErrorActionPreference = 'Stop'
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$bashCandidates = @()
$bashCommand = Get-Command bash.exe -ErrorAction SilentlyContinue
if ($bashCommand) {
$bashCandidates += $bashCommand.Source
}
$bashCandidates += @(
'C:\Program Files\Git\bin\bash.exe',
'C:\Program Files\Git\usr\bin\bash.exe',
'C:\Program Files (x86)\Git\bin\bash.exe',
'C:\Program Files (x86)\Git\usr\bin\bash.exe'
)
$bashPath = $bashCandidates | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1
if ($bashPath) {
& $bashPath "$scriptRoot/install.sh" @InstallerArgs
exit $LASTEXITCODE
}
$wslCommand = Get-Command wsl.exe -ErrorAction SilentlyContinue
if ($wslCommand) {
$linuxScriptPath = (& $wslCommand.Source wslpath -a "$scriptRoot/install.sh").Trim()
if (-not $linuxScriptPath) {
throw 'Failed to convert install.sh to a WSL path.'
}
& $wslCommand.Source bash $linuxScriptPath @InstallerArgs
exit $LASTEXITCODE
}
throw 'Neither Git Bash nor WSL was found. Install Git for Windows or enable WSL, then rerun install.ps1.'