-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
41 lines (35 loc) · 1.05 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
$ErrorActionPreference = 'Stop';
if (($PSVersionTable.PSVersion.Major) -lt 5) {
Write-Warning "PowerShell 5 or later is required to run this install script."
Write-Warning "Please upgrade: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell"
break
}
function Test-CommandExists {
param(
[string]$commandName
)
$oldPref = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
try {
if (Get-Command $commandName) {
return $true
}
}
catch {
return $false
}
finally {
$ErrorActionPreference = $oldPref
}
}
# Install chezmoi if it's not already installed
if (-not (Test-CommandExists 'chezmoi')) {
$BinDir = "~\.local\bin"
$ChezmoiBin = Join-Path $BinDir 'chezmoi'
"`$params = `"-BinDir ${BinDir}`"", (Invoke-WebRequest https://git.io/chezmoi.ps1).Content | powershell -c -
}
else {
$ChezmoiBin = 'chezmoi'
}
$ChezmoiInitCmd = "$ChezmoiBin init --apply --source=$PSScriptRoot"
Invoke-Expression $ChezmoiInitCmd