forked from giggio/poshfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallTools.ps1
43 lines (42 loc) · 1.84 KB
/
InstallTools.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
42
43
$root = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$ErrorActionPreference = 'stop'
$bin = "$root/bin"
$env:PATH += $([System.IO.Path]::PathSeparator) + $bin
if (!(Test-Path $bin)) { New-Item -Type Directory $bin | Out-Null }
$os = ''
if ($IsWin) {
$os = 'windows'
} elseif ($IsLinux) {
$os = 'linux'
return # let's not support Linux yet, it blows up
}
if (!(Test-Path $bin/tflint*)) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tmpFile = (New-TemporaryFile).FullName
Invoke-WebRequest "https://github.com/wata727/tflint/releases/download/v0.7.0/tflint_$($os)_amd64.zip" -OutFile $tmpFile
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($tmpFile, $bin)
Remove-Item $tmpFile
}
if ($IsWin) {
if (Get-Command fzf -ErrorAction Ignore) {
function CreateFzfPsm1() {
if (!(Test-Path "$root/Modules/PSFzf/PSFzf.psm1")) {
Write-Host "Creating $root/Modules/PSFzf/PSFzf.psm1..."
. "$root/Modules/PSFzf/helpers/Join-ModuleFiles.ps1"
}
}
if (!(Test-Path "$root/Modules/PSFzf/PSFzf.dll")) {
if (Get-Command dotnet -ErrorAction Ignore) {
$fzfTempDir = Join-Path "$([System.IO.Path]::GetTempPath())" fzf
New-Item -Type Directory $fzfTempDir -Force | Out-Null
dotnet build --nologo --verbosity quiet --configuration Release --output $fzfTempDir "$root/Modules/PSFzf/PSFzf-Binary/PSFzf-Binary.csproj"
Copy-Item $fzfTempDir/PSFzf.dll "$root/Modules/PSFzf/"
CreateFzfPsm1
Import-Module "$root/Modules/PSFzf/PSFzf.psd1" -ArgumentList 'Ctrl+t', 'Ctrl+r' -Force
Remove-Item -Force -Recurse $fzfTempDir
}
}
CreateFzfPsm1
}
}